IOS application cold start acceleration and memory optimization method and system
By establishing a three-level monitoring system and a hierarchical loading strategy, and combining path prediction and hierarchical loading strategies, the resource loading strategy is dynamically adjusted according to device performance and real-time scenarios. This solves the problems of slow cold start speed and high memory consumption of iOS applications, and achieves faster startup speed and higher memory efficiency.
Patent Information
- Application Number
- CN202511283433.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-09
- Publication Date
- 2025-12-16
AI Technical Summary
iOS apps suffer from slow startup speed, high memory usage, and poor user experience during cold starts. Existing optimization solutions cannot achieve a good balance between startup speed and memory efficiency, and are difficult to adapt to the performance differences of different devices.
A three-level monitoring system was established. The core function calls of the dyld loader were captured by hook technology. The improved Markov chain algorithm was used for path prediction, resources were loaded in stages, and the loading strategy was dynamically adjusted according to device performance and real-time scenario. Image resources were compressed in ASTC format and data was compressed using the LZ4 algorithm.
Significantly reduces cold start time by over 40%, reduces peak memory usage by 30%, improves user experience, is compatible with all iOS 12 and above, and covers over 90% of active devices.
Smart Images

Figure CN121143902A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of mobile terminal performance optimization technology, and in particular to a method and system for accelerating cold starts and optimizing memory in iOS applications. Background Technology
[0002] With the rapid development of mobile internet, iOS devices (such as iPhones and iPads) have become indispensable tools in people's daily lives. However, iOS applications often face problems such as slow startup speed, high memory consumption, and poor user experience during cold starts. These problems mainly stem from the following aspects:
[0003] First, system-level limitations lead to excessively long startup times. iOS's security sandbox mechanism restricts pre-loading resources, and the library loading process of the dyld dynamic linker accounts for more than 40% of the total startup time on average. Real-world testing data shows that the cold start time for mainstream social applications generally exceeds 2 seconds, while e-commerce applications often reach more than 3 seconds.
[0004] Secondly, existing optimization solutions have significant flaws. Apple's official prefetch API lacks user behavior awareness, and its resource preloading accuracy is less than 60%. Third-party solutions, such as segmented loading, can cause UI flickering, while hot update solutions require additional server support. None of these solutions achieve a good balance between startup speed and memory efficiency.
[0005] Third, poor memory management exacerbates startup problems. Excessive preloading can lead to excessively high memory spikes, easily triggering iOS's Jetsam mechanism to forcibly terminate the application. Data shows that unreasonable preloading can cause more than 40% of memory resources to be wasted.
[0006] Furthermore, differences in device performance also increase the difficulty of optimization. The same app can launch with performance differences of more than 50% on the iPhone SE and iPhone Pro Max, making it difficult to adapt a single optimization strategy to all devices. Summary of the Invention
[0007] Based on this, this application provides a method and system for accelerating cold starts and optimizing memory in iOS applications. By establishing a three-level optimization system of startup monitoring, path prediction, and hierarchical loading, this application effectively solves the performance bottleneck of cold starts in iOS applications.
[0008] Firstly, a method for accelerating cold starts and optimizing memory usage in iOS applications is provided, which includes:
[0009] A three-tiered monitoring system comprising the system layer, framework layer, and business layer is established to acquire monitoring data. The system layer uses hook technology to capture the core function calls of the dyld loader and accurately record the dynamic library loading sequence. The framework layer implements event tracking for key UIKit lifecycle methods. The business layer uses a lightweight event tracking SDK to record the initialization time of each module. The monitoring data is stored in a shared memory area using a circular buffer design.
[0010] The path prediction result is obtained through a path prediction model based on monitoring data; wherein, the path prediction model predicts the application resources that the user may access after the application is launched based on user behavior sequence, historical behavior pattern and real-time environmental characteristics.
[0011] Based on the path prediction results, application resources are divided into different priorities and loaded according to priority order;
[0012] Based on device performance and real-time scenarios, the resource loading strategy is dynamically adjusted to achieve optimized results; this includes the priority and timing of resource loading.
[0013] Optionally, the path prediction model employs an improved Markov chain algorithm, the specific implementation of which includes:
[0014] The system processes user recent behavior sequences, historical behavior patterns, real-time environmental features, and business context features, uses kernel density estimation to handle sparse paths, and employs the EM algorithm for parameter optimization.
[0015] The model is incrementally updated according to a set time, and the access probability of each functional module is output by inputting the user's three most recent operation paths.
[0016] Optionally, based on the path prediction results, application resources are divided into different priority levels: P0, P1, and P2.
[0017] P0-level resources include all views within the visible area of the first screen, entry buttons for core business functions, and basic framework code;
[0018] P1 level resources include secondary page view controllers, non-first screen image resources, and non-core business logic code;
[0019] P2 level resources include low-frequency functional modules, long-tail content, and auxiliary tool code.
[0020] Optionally, loading can be categorized according to priority, including:
[0021] P0-level resources are loaded in parallel at startup, with a maximum of 4 threads; P1-level resources are loaded when the RunLoop is idle, with a thread limit of 2; P2-level resources are preloaded in the background when the prediction confidence is greater than 85%.
[0022] Image resources are compressed using the ASTC format, and data is compressed using the LZ4 algorithm to optimize memory usage.
[0023] Optionally, the resource loading strategy can be dynamically adjusted based on device performance and real-time scenario to obtain optimized results, including:
[0024] The system API is called to obtain device model information and determine device performance, and the resource loading strategy is dynamically adjusted according to the device performance. Among them, devices with model A14 and above are high-performance devices, A12-A13 are mid-range devices, and A11 and below are low-end devices.
[0025] When the testing equipment is a high-performance device, load P0 and P1 level resources;
[0026] When the testing equipment is a mid-range device, only P0 level resources are loaded;
[0027] When the testing equipment is a low-end device, P0-level resources are loaded in blocks.
[0028] Optionally, the resource loading strategy can be dynamically adjusted based on device performance and real-time scenario to obtain optimized results, including:
[0029] In low power mode, increase the weight of P0 level resources, prioritize loading critical resources, and reduce the loading of unnecessary resources.
[0030] In a WiFi environment, the loading restrictions for P1 level resources are relaxed, allowing more resources to be preloaded in the background;
[0031] Under high temperature conditions, the device is forced into compression mode to reduce resource loading and lower equipment load; specifically, high temperature conditions refer to equipment temperatures > 45℃.
[0032] In the background, pause the loading of all non-P0 level resources and retain only critical resources to save system resources.
[0033] Secondly, an iOS application cold start acceleration and memory optimization system is provided, which includes:
[0034] The monitoring module is used to establish a three-level monitoring system including the system layer, framework layer, and business layer, and to acquire monitoring data. The system layer uses hook technology to capture the core function calls of the dyld loader and accurately record the dynamic library loading sequence. The framework layer performs instrumentation on key lifecycle methods of UIKit. The business layer uses a lightweight instrumentation SDK to record the initialization time of each module. The monitoring data is stored in a shared memory area and adopts a circular buffer design.
[0035] The prediction module is used to obtain path prediction results based on monitoring data through a path prediction model; wherein, the path prediction model predicts the application resources that the user may access after the application starts based on user behavior sequences, historical behavior patterns and real-time environmental characteristics.
[0036] The loading module is used to divide application resources into different priorities based on path prediction results and load them according to priority order.
[0037] The optimization module is used to dynamically adjust the resource loading strategy based on device performance and real-time scenarios to obtain optimized results; this includes the priority and timing of resource loading.
[0038] Thirdly, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement any of the methods described in the first aspect above.
[0039] Fourthly, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements any of the methods described in the first aspect above.
[0040] Fifthly, a computer program product is provided, on which a computer program is stored, which, when executed by a processor, implements any of the methods described in the first aspect above.
[0041] The beneficial effects of the technical solutions provided in this application include at least the following:
[0042] In terms of startup speed, through precise path prediction and hierarchical loading, the cold start time of typical applications can be reduced by more than 40%. Compared with traditional global preloading schemes, this method achieves better acceleration results with the same memory usage.
[0043] In terms of memory efficiency, intelligent resource management reduces peak memory usage by more than 30%, significantly decreasing the risk of applications being forcibly terminated by the system. Real-world testing shows that the optimized application experiences a 60% reduction in crash rate on devices with low memory, such as the iPhone SE.
[0044] In terms of compatibility, this solution supports all iOS 12 and above, covering over 90% of active devices. Existing optimization solutions typically only support the latest system version. Attached Figure Description
[0045] To more clearly illustrate the embodiments of this application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are merely exemplary, and those skilled in the art can derive other embodiments based on the provided drawings without creative effort.
[0046] Figure 1 A flowchart illustrating the steps of an iOS application cold start acceleration and memory optimization method provided in this application embodiment;
[0047] Figure 2 A block diagram of an iOS application cold start acceleration and memory optimization system provided in this application embodiment;
[0048] Figure 3 This is a schematic diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0049] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0050] In the description of this application, the terms "comprising," "having," and any variations thereof are intended to cover non-exclusive inclusion, such as a process, method, system, product, or apparatus that includes a series of steps or units, not necessarily limited to those steps or units that are expressly listed, but may also include other steps or units that are not expressly listed but are inherent to these processes, methods, products, or apparatuses, or steps or units added based on further optimizations conceived in this application.
[0051] There are currently three main technical bottlenecks in the cold start of iOS applications:
[0052] First, system-level limitations lead to excessively long startup times. iOS's security sandbox mechanism restricts pre-loading resources, and the library loading process of the dyld dynamic linker accounts for more than 40% of the total startup time on average. Real-world testing data shows that the cold start time for mainstream social applications generally exceeds 2 seconds, while e-commerce applications often reach more than 3 seconds.
[0053] Secondly, existing optimization solutions have significant flaws. Apple's official prefetch API lacks user behavior awareness, and its resource preloading accuracy is less than 60%. Third-party solutions, such as segmented loading, can cause UI flickering, while hot update solutions require additional server support. None of these solutions achieve a good balance between startup speed and memory efficiency.
[0054] Third, poor memory management exacerbates startup problems. Excessive preloading can lead to excessively high memory spikes, easily triggering iOS's Jetsam mechanism to forcibly terminate the application. Data shows that unreasonable preloading can cause more than 40% of memory resources to be wasted.
[0055] Furthermore, differences in device performance also increase the difficulty of optimization. The same app can launch with performance differences of more than 50% on the iPhone SE and iPhone Pro Max, making it difficult to adapt a single optimization strategy to all devices.
[0056] These technical pain points urgently require an innovative solution that can intelligently predict user behavior and precisely control resource loading. This application presents a solution in this context.
[0057] This application belongs to the field of iOS application performance optimization technology, specifically involving an innovative method to accelerate application cold starts through intelligent preloading and dynamic memory management. This technology primarily addresses issues such as slow startup speed, high memory consumption, and poor user experience during application startup on iPhone and iPad devices, providing a system-level optimization solution.
[0058] This application's technical boundaries are clearly defined as optimizing the application startup process of the iOS system. Through innovative startup path prediction and resource hierarchical loading mechanisms, it significantly improves startup speed while ensuring system stability. Compared with traditional startup optimization techniques, this solution has two innovative features: high accuracy in behavior prediction and high memory utilization efficiency, enabling more intelligent performance optimization.
[0059] This application proposes a cold start acceleration method based on user behavior prediction. By establishing a three-level optimization system of startup monitoring, path prediction, and hierarchical loading, it effectively solves the performance bottleneck of iOS application cold start.
[0060] This solution first establishes a complete startup process monitoring system, encompassing three levels of monitoring: system layer, framework layer, and business layer. At the system level, core function calls of the dyld loader are captured using hook technology to accurately record the dynamic library loading sequence; at the framework layer, key lifecycle methods of UIKit are tracked; and at the business layer, a lightweight tracking SDK records the initialization time of each module. Monitoring data is stored in a shared memory area using a circular buffer design.
[0061] Based on monitoring data, the solution establishes a path prediction model based on an improved Markov chain algorithm. This model comprehensively considers recent user behavior sequences, historical behavior patterns, and real-time environmental characteristics, and optimizes parameters using the EM algorithm, achieving a prediction accuracy of 89.2%. The model is updated incrementally every 30 minutes, with prediction time controlled within 5ms.
[0062] Regarding resource loading, this application designs a dynamic hierarchical strategy, dividing application resources into three priorities: P0 level (first-screen visible content, core functions) is loaded immediately; P1 level (secondary page resources) is loaded with a delay; and P2 level (low-frequency functions) is loaded on demand. Simultaneously, image resources are compressed using the ASTC format, and data is compressed using the LZ4 algorithm, reducing memory usage by more than 35%.
[0063] Please refer to Figure 1 The document illustrates a flowchart of an iOS application cold start acceleration and memory optimization method provided in an embodiment of this application. The method may include the following steps:
[0064] S1. Establish a three-tiered monitoring system comprising the system layer, framework layer, and business layer, and acquire monitoring data.
[0065] The system layer uses hook technology to capture the core function calls of the dyld loader and accurately record the loading sequence of dynamic libraries; the framework layer implements instrumentation for key lifecycle methods of UIKit; and the business layer uses a lightweight instrumentation SDK to record the initialization time of each module, with the monitoring data stored in a shared memory area using a circular buffer design.
[0066] S2, based on monitoring data, obtains path prediction results through a path prediction model.
[0067] The path prediction model predicts the application resources that a user may access after the application is launched, based on user behavior sequences, historical behavior patterns, and real-time environmental characteristics.
[0068] The path prediction model uses an improved Markov chain algorithm. The specific implementation process includes: processing user recent behavior sequences, historical behavior patterns, real-time environmental features, and business context features; using kernel density estimation to process sparse paths; using the EM algorithm to optimize parameters; and incrementally updating the model according to a set time. By inputting the user's three most recent operation paths, the model outputs the access probability of each functional module.
[0069] S3 divides application resources into different priorities based on path prediction results and loads them according to priority order.
[0070] In this embodiment of the application, application resources are divided into different priorities based on path prediction results. The application resources are divided into P0, P1, and P2 levels, where:
[0071] P0-level resources include all views within the visible area of the first screen, entry buttons for core business functions, and basic framework code;
[0072] P1 level resources include secondary page view controllers, non-first screen image resources, and non-core business logic code;
[0073] P2 level resources include low-frequency functional modules, long-tail content, and auxiliary tool code.
[0074] Loading is done in order of priority, including:
[0075] P0-level resources are loaded in parallel at startup, with a maximum of 4 threads; P1-level resources are loaded when the RunLoop is idle, with a thread limit of 2; P2-level resources are preloaded in the background when the prediction confidence is greater than 85%.
[0076] Image resources are compressed using the ASTC format, and data is compressed using the LZ4 algorithm to optimize memory usage.
[0077] S4 dynamically adjusts the resource loading strategy based on device performance and real-time scenarios to achieve optimized results.
[0078] This includes the priority and timing of resource loading.
[0079] In this embodiment, the resource loading strategy is dynamically adjusted based on device performance and real-time scenario to obtain optimized results, including:
[0080] The system API is called to obtain device model information and determine device performance, and the resource loading strategy is dynamically adjusted according to the device performance. Among them, devices with model A14 and above are high-performance devices, A12-A13 are mid-range devices, and A11 and below are low-end devices.
[0081] When the testing equipment is a high-performance device, load P0 and P1 level resources;
[0082] When the testing equipment is a mid-range device, only P0 level resources are loaded;
[0083] When the testing equipment is a low-end device, P0-level resources are loaded in blocks.
[0084] Based on device performance and real-time scenarios, the resource loading strategy is dynamically adjusted to achieve optimized results, including:
[0085] In low power mode, increase the weight of P0 level resources, prioritize loading critical resources, and reduce the loading of unnecessary resources.
[0086] In a WiFi environment, the loading restrictions for P1 level resources are relaxed, allowing more resources to be preloaded in the background;
[0087] Under high temperature conditions, the device is forced into compression mode to reduce resource loading and lower equipment load; specifically, high temperature conditions refer to equipment temperatures > 45℃.
[0088] In the background, pause the loading of all non-P0 level resources and retain only critical resources to save system resources.
[0089] In summary, the core innovations of this application are mainly reflected in the following aspects:
[0090] In terms of startup monitoring, a multi-level data tracking system enables precise monitoring of the entire cold start process. An innovative circular buffer is used to store monitoring data, keeping memory usage below 10MB, thus providing a reliable data foundation for optimization.
[0091] Dynamic path prediction is a major innovation of this solution. This technology, through an improved Markov chain model, comprehensively considers features such as time decay factors and sliding window mean, increasing preloading accuracy from the industry average of 58% to 89%. The model supports online incremental updates, ensuring the timeliness of predictions.
[0092] In terms of memory management, the unique "three-level response" mechanism can intelligently cope with system memory pressure: Level 0 loads normally; Level 1 stops P1 loading; Level 2 releases P1 resources; Level 3 retains only visible P0 resources. Through CADisplayLink, a smooth 60FPS degradation process is achieved, ensuring both system stability and maintaining a good user experience.
[0093] Specifically, test data applied to an iPhone 13 Pro (iOS 15.4) using this method showed that the optimized application cold start time was reduced from 2.8 seconds to 1.6 seconds, and the peak memory usage decreased from 247MB to 172MB. The probability of CPU temperature exceeding 60℃ in high-temperature scenarios decreased from 65% to 15%. These optimization effects have been verified in various application types, including e-commerce, social media, and news.
[0094] This technology is particularly suitable for iOS applications that are sensitive to startup speed. In social media, e-commerce, and utility applications, it can significantly improve user experience and has significant commercial value. As the performance requirements of iOS devices continue to increase, this type of system-level optimization technology will demonstrate even greater application potential.
[0095] This application contains several core technologies, namely: parameter combination of the startup path prediction model, dynamic adjustment formula of memory compression ratio, and implementation method of system monitoring point embedding. These core technologies are protected by multiple measures such as code obfuscation and parameter encryption.
[0096] It should be noted that in this embodiment, only iOS 12+ systems using the dyld3 loader are applicable, the optimization target is limited to legitimate applications in Mach-O format, jailbroken devices and other unofficial operating environments are explicitly excluded, and all technical implementations are completed through legitimate APIs or reverse engineering methods.
[0097] The following is a supplement to the specific technical content of the above embodiments:
[0098] This solution specifically includes the following key technologies:
[0099] 1. Detailed implementation of monitoring startup
[0100] (1) System-level monitoring
[0101] By using hooking technology to capture the core function calls of the dyld loader, the dynamic library loading sequence can be precisely recorded. Monitoring points include:
[0102] _dyld_start start timestamp;
[0103] The completion time of dyld3's notifySingleProcessing;
[0104] Execution time of libSystem_initializer;
[0105] objc_init runtime initialization time.
[0106] (2) Framework layer monitoring
[0107] Track events for key UIKit lifecycle methods:
[0108] The `application:didFinishLaunchingWithOptions` function is the entry point for this feature.
[0109] viewDidLoad of rootViewController;
[0110] The first screen view's viewWillAppear / viewDidAppear;
[0111] CA::Transaction::commit() renders the commit time.
[0112] (3) Business layer monitoring
[0113] Recorded using a lightweight event tracking SDK:
[0114] The initialization start / end time of each business module; the time difference between network request initiation and callback; the loading time of the core data model; monitoring data is stored in a shared memory area, using a circular buffer design, and retaining the data from the most recent 50 startups, with memory usage controlled within 10MB.
[0115] 2. Implementation details of the path prediction model
[0116] The prediction model in this scheme is based on an improved Markov chain algorithm, and its specific implementation includes:
[0117] (1) Feature Engineering
[0118] User's recent behavior sequence (time decay factor 0.7).
[0119] Historical behavioral patterns (sliding window with 7-day average).
[0120] Real-time environmental characteristics (network type, device temperature, etc.).
[0121] Business context features (such as the number of items in an e-commerce shopping cart).
[0122] (2) Model Training
[0123] Kernel density estimation is used to handle sparse paths.
[0124] Parameter optimization is performed using the EM algorithm.
[0125] The offline training period is 24 hours.
[0126] The online model is updated incrementally every 30 minutes.
[0127] (3) Predictive execution
[0128] Input: The user's three most recent operation paths.
[0129] Output: Access probability of each functional module.
[0130] Real-time performance: Prediction time < 5ms.
[0131] Accuracy: 89.2% on the test set.
[0132] 3. Specific Implementation of the Tiered Loading Strategy
[0133] The specific implementation of the resource tiering and loading scheme:
[0134] (1) Resource classification standards
[0135] P0 level (loads immediately):
[0136] All views within the visible area of the first screen, entry buttons for core business functions, and basic framework code (such as network libraries and image libraries).
[0137] P1 level (lazy loading):
[0138] Secondary page view controllers, non-first screen image resources, and non-core business logic code.
[0139] Level P2 (Load on Demand):
[0140] Low-frequency functional modules, long-tail content such as historical records, and auxiliary utility code.
[0141] (2) Dynamic loading mechanism
[0142] P0 level: Parallel loading at startup, maximum number of threads 4; P1 level: Loading when RunLoop is idle, thread count limited to 2; P2 level: Background preloading when prediction confidence > 85%.
[0143] (3) Memory compression scheme
[0144] Image resources: ASTC format compressed (6:1).
[0145] JSON data: compressed using the LZ4 algorithm.
[0146] View hierarchy: Optimize layout using UIStackView.
[0147] Object pool: A mechanism for frequently creating and reusing objects.
[0148] 4. Technical Details of Dynamic Hierarchical Strategy
[0149] Specific implementation of the adaptive hierarchical strategy:
[0150] (1) Equipment performance adaptation
[0151] High-performance device (A14+): Load P0+P1.
[0152] Mid-range devices (A12-A13): Only load P0.
[0153] Low-end devices (A11-): P0 block loading.
[0154] Detection method: Obtain hw.machine via sysctlbyname.
[0155] (2) Scene Awareness Strategy
[0156] Low power mode: Increase P0 weight to 0.9.
[0157] WiFi environment: Relax P1 loading restrictions.
[0158] High temperature condition (>45℃): Forced compression mode.
[0159] Background status: Pause all non-P0 loading.
[0160] (3) Gradual Degradation Scheme
[0161] Level 0: Full loading strategy.
[0162] Level 1: Stop loading P1.
[0163] Level 2: Release loaded P1 resources.
[0164] Level 3: Only retain visible P0 resources.
[0165] Downgrade threshold: determined based on memorystatus_level.
[0166] All strategy transitions incorporate a 0.3-second gradual animation to ensure visual continuity. A smooth 60FPS degradation process is achieved through CADisplayLink, avoiding abrupt interface changes.
[0167] Please refer to Figure 2 The diagram illustrates a block diagram of an iOS application cold start acceleration and memory optimization system provided in an embodiment of this application. The system may include:
[0168] The monitoring module is used to establish a three-level monitoring system including the system layer, framework layer, and business layer, and to acquire monitoring data. The system layer uses hook technology to capture the core function calls of the dyld loader and accurately record the dynamic library loading sequence. The framework layer performs instrumentation on key lifecycle methods of UIKit. The business layer uses a lightweight instrumentation SDK to record the initialization time of each module. The monitoring data is stored in a shared memory area and adopts a circular buffer design.
[0169] The prediction module is used to obtain path prediction results based on monitoring data through a path prediction model; wherein, the path prediction model predicts the application resources that the user may access after the application starts based on user behavior sequences, historical behavior patterns and real-time environmental characteristics.
[0170] The loading module is used to divide application resources into different priorities based on path prediction results and load them according to priority order.
[0171] The optimization module is used to dynamically adjust the resource loading strategy based on device performance and real-time scenarios to obtain optimized results; this includes the priority and timing of resource loading.
[0172] For specific limitations regarding the iOS application cold start acceleration and memory optimization system, please refer to the limitations of the iOS application cold start acceleration and memory optimization methods mentioned above, which will not be repeated here. Each module in the aforementioned iOS application cold start acceleration and memory optimization system can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or they can be stored in the memory of a computer device in software form, so that the processor can call and execute the corresponding operations of each module.
[0173] In one embodiment, an electronic device is provided, which may be a computer, and its internal structure diagram may be as follows: Figure 3 As shown, the electronic device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage medium. The database of the computer device is used for iOS application cold start acceleration and memory optimization data. The network interface of the computer device is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements a method for iOS application cold start acceleration and memory optimization.
[0174] Those skilled in the art will understand that, Figure 3 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0175] In one embodiment of this application, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the above-described iOS application cold start acceleration and memory optimization method.
[0176] In one embodiment of this application, a computer program product is provided, including a computer program / instructions, which, when executed by a processor, implements the steps of the above-described iOS application cold start acceleration and memory optimization method.
[0177] The computer-readable storage medium and computer program product provided in this embodiment are similar in implementation principle and technical effect to the above method embodiments, and will not be repeated here.
[0178] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in M forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), memory bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0179] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0180] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A method for accelerating cold starts and optimizing memory in iOS applications, characterized in that, The method includes: A three-tiered monitoring system comprising the system layer, framework layer, and business layer is established to acquire monitoring data. The system layer uses hook technology to capture the core function calls of the dyld loader and accurately record the dynamic library loading sequence. The framework layer implements event tracking for key UIKit lifecycle methods. The business layer uses a lightweight event tracking SDK to record the initialization time of each module. The monitoring data is stored in a shared memory area using a circular buffer design. The path prediction result is obtained through a path prediction model based on monitoring data; wherein, the path prediction model predicts the application resources that the user may access after the application is launched based on user behavior sequence, historical behavior pattern and real-time environmental characteristics. Based on the path prediction results, application resources are divided into different priorities and loaded according to priority order; Based on device performance and real-time scenarios, the resource loading strategy is dynamically adjusted to achieve optimized results; this includes the priority and timing of resource loading.
2. The method according to claim 1, characterized in that, The path prediction model employs an improved Markov chain algorithm, and its specific implementation includes: The system processes user recent behavior sequences, historical behavior patterns, real-time environmental features, and business context features, uses kernel density estimation to handle sparse paths, and employs the EM algorithm for parameter optimization. The model is incrementally updated according to a set time, and the access probability of each functional module is output by inputting the user's three most recent operation paths.
3. The method according to claim 1, characterized in that, Based on the path prediction results, application resources are divided into different priorities: P0, P1, and P2. P0-level resources include all views within the visible area of the first screen, entry buttons for core business functions, and basic framework code; P1 level resources include secondary page view controllers, non-first screen image resources, and non-core business logic code; P2 level resources include low-frequency functional modules, long-tail content, and auxiliary tool code.
4. The method according to claim 3, characterized in that, Loading is done in order of priority, including: P0-level resources are loaded in parallel at startup, with a maximum of 4 threads; P1-level resources are loaded when the RunLoop is idle, with a thread limit of 2; P2-level resources are preloaded in the background when the prediction confidence is greater than 85%. Image resources are compressed using the ASTC format, and data is compressed using the LZ4 algorithm to optimize memory usage.
5. The method according to claim 4, characterized in that, Based on device performance and real-time scenarios, the resource loading strategy is dynamically adjusted to achieve optimized results, including: The system API is called to obtain device model information and determine device performance, and the resource loading strategy is dynamically adjusted according to the device performance. Among them, devices with model A14 and above are high-performance devices, A12-A13 are mid-range devices, and A11 and below are low-end devices. When the testing equipment is a high-performance device, load P0 and P1 level resources; When the testing equipment is a mid-range device, only P0 level resources are loaded; When the testing equipment is a low-end device, P0-level resources are loaded in blocks.
6. The method according to claim 4, characterized in that, Based on device performance and real-time scenarios, the resource loading strategy is dynamically adjusted to achieve optimized results, including: In low power mode, increase the weight of P0 level resources, prioritize loading critical resources, and reduce the loading of unnecessary resources. In a WiFi environment, the loading restrictions for P1 level resources are relaxed, allowing more resources to be preloaded in the background; Under high temperature conditions, the device is forced into compression mode to reduce resource loading and lower equipment load; specifically, high temperature conditions refer to equipment temperatures > 45℃. In the background, pause the loading of all non-P0 level resources and retain only critical resources to save system resources.
7. An iOS application cold start acceleration and memory optimization system, characterized in that, The system includes: The monitoring module is used to establish a three-level monitoring system including the system layer, framework layer, and business layer, and to acquire monitoring data. The system layer uses hook technology to capture the core function calls of the dyld loader and accurately record the dynamic library loading sequence. The framework layer performs instrumentation on key lifecycle methods of UIKit. The business layer uses a lightweight instrumentation SDK to record the initialization time of each module. The monitoring data is stored in a shared memory area and adopts a circular buffer design. The prediction module is used to obtain path prediction results based on monitoring data through a path prediction model; wherein, the path prediction model predicts the application resources that the user may access after the application starts based on user behavior sequences, historical behavior patterns and real-time environmental characteristics. The loading module is used to divide application resources into different priorities based on path prediction results and load them according to priority order. The optimization module is used to dynamically adjust the resource loading strategy based on device performance and real-time scenarios to obtain optimized results; this includes the priority and timing of resource loading.
8. An electronic device, characterized in that, It includes a memory and a processor, the memory storing a computer program that, when executed by the processor, implements the method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the method as described in any one of claims 1 to 6.
10. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the method described in any one of claims 1 to 6.