Memory management method and device of application program, terminal and storage medium
Efficient and accurate memory management is achieved by pre-stored the memory preference configuration of applications in the Android operating system and passing them into the ART virtual machine.
Patent Information
- Application Number
- CN202311138997.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-04
- Publication Date
- 2025-03-04
AI Technical Summary
In the Android operating system, how to provide the best memory management strategy for each application must not only improve memory management efficiency but also ensure accuracy.
By pre-stored the memory preference configurations of each application in the AMS's array container, these configurations are passed into the ART virtual machine during the application startup phase, which adjusts the application's memory management policy based on these configurations.
It implements different memory management strategies for different applications, and configures memory management policies for each application in a targeted manner, improving the memory management efficiency and accuracy of the application.
Smart Images

Figure CN119557040A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a method, device, terminal and storage medium for memory management of an application. Background Art
[0002] GC (Garbage Collection) is an automatic memory management mechanism. When running an application, memory space needs to be allocated for objects in the application. When the objects are no longer referenced or cannot be accessed, the memory space occupied by them becomes useless (i.e., becomes garbage). The role of GC is to automatically release the memory space occupied by these garbage objects and recycle it back to the system for use by other objects.
[0003] The GC memory management mechanism is implemented by the allocator and the collector. The allocator is used to allocate memory space to newly created objects. The collector periodically scans and checks the objects in the heap memory, marking all objects that are still referenced (i.e. active objects). Objects that are not marked are considered garbage. The collector releases the memory space occupied by garbage and makes it available.
[0004] Android's ART (Android Runtime) provides multiple memory spaces and is equipped with several types of allocators and collectors. Each allocator / collector type is suitable for certain scenarios and has its own advantages and disadvantages for memory processing. How to provide the best memory management strategy for each application in ART is an urgent problem to be solved. Summary of the invention
[0005] The embodiment of the present application provides a method, device, terminal and storage medium for memory management of an application. The technical solution is as follows:
[0006] According to one aspect of the present application, a memory management method for an application is provided, the method being executed by a terminal, the method comprising:
[0007] Storing a memory configuration file in an array container of an AMS (ActivityManagerService); the memory configuration file includes: at least one application, and memory preference configurations corresponding to the at least one application; the at least one application includes a first application;
[0008] During the application startup phase of the first application, the first memory preference configuration corresponding to the first application is transmitted to the ART virtual machine through the AMS;
[0009] The memory management policy of the first application is adjusted based on the first memory preference configuration by the ART virtual machine.
[0010] According to another aspect of the present application, a memory management device for an application is provided, the device comprising:
[0011] A system service module, configured to store a memory configuration file into an array container of the AMS; the memory configuration file includes: at least one application program, and memory preference configurations respectively corresponding to the at least one application program; the at least one application program includes a first application program;
[0012] The system service module is used to transfer the first memory preference configuration corresponding to the first application to the ART virtual machine through the AMS during the application startup phase of the first application;
[0013] An application module is used to adjust the memory management policy of the first application based on the first memory preference configuration through the ART virtual machine.
[0014] According to another aspect of the present application, a terminal is provided, the terminal comprising a processor and a memory, the memory storing at least one instruction, the instruction being loaded and executed by the processor to implement a memory management method of an application program as provided in the present application.
[0015] According to another aspect of the present application, a computer-readable storage medium is provided, wherein at least one instruction is stored in the storage medium, and the instruction is loaded and executed by a processor to implement a memory management method of an application program as provided in the implementation of the present application.
[0016] The beneficial effects brought by the technical solution provided by the embodiments of the present application may include:
[0017] The memory preference configuration of each application is pre-stored in the array container of AMS. During the startup phase of the application, when the startup process is executed to AMS, AMS can read the memory preference configuration corresponding to the application from the pre-stored memory configuration file and pass the memory preference configuration to the ART virtual machine. When the ART virtual machine runs the application, it can set the memory management policy of the application according to the memory preference configuration, so that different applications adopt different memory management policies, configure memory management policies for each application in a targeted manner, and improve the memory management efficiency and accuracy of the application. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly introduce the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1 is a schematic diagram of an Android operating system startup process provided by an exemplary embodiment of the present application;
[0020] Figure 2 is a schematic diagram of an application startup process provided by an exemplary embodiment of the present application;
[0021] Figure 3 is a schematic diagram of a terminal provided by an exemplary embodiment of the present application;
[0022] Figure 4 is a flowchart of a memory management method of an application provided by another exemplary embodiment of the present application;
[0023] Figure 5 is a flowchart of a memory management method of an application provided by an exemplary embodiment of the present application;
[0024] Figure 6 is a schematic diagram of a memory management method for an application provided by an exemplary embodiment of the present application;
[0025] Figure 7 is a schematic diagram of a memory management method of an application provided by another exemplary embodiment of the present application;
[0026] Figure 8 is a schematic diagram of a memory management method of an application provided by another exemplary embodiment of the present application;
[0027] Fig. 9 is a structural block diagram of a memory management device for an application provided by an exemplary embodiment of the present application;
[0028] Fig.10 It is a structural block diagram of a terminal provided by an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0029] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0030] When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.
[0031] In the description of the present application, it should be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In the description of the present application, it should be noted that, unless otherwise clearly specified and limited, the terms "connected" and "connected" should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be directly connected or indirectly connected through an intermediate medium. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances. In addition, in the description of the present application, unless otherwise specified, "multiple" means two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship.
[0032] First, some terms involved in this application are introduced and explained. The following introduction and explanation as optional solutions can be arbitrarily combined with the technical solutions of the embodiments of this application, and they all belong to the protection scope of the embodiments of this application.
[0033] AMS (Activity Manager Service) is one of the important system services in the Android system. It is the component in the Android system responsible for managing and scheduling application activities. AMS is responsible for starting and managing application activities. It receives application start requests, creates and destroys corresponding activities, and provides interfaces for interacting with activities. AMS provides applications with a good user experience and smooth interface interaction by effectively managing operations such as starting, destroying, switching, and communicating with activities.
[0034] ART (Android Runtime) is the application runtime environment of the Android system. ART provides various functions and interfaces required for application operation, as well as management and scheduling of application operation. ART is responsible for converting the bytecode of the application into machine code, and provides runtime functions such as garbage collection and memory allocation. There are two options for the runtime environment of the Android system: Dalvik Runtime (DVM) and Android Runtime (ART). Dalvik Runtime is the runtime environment used before Android 4.4 KitKat, while ART is the default runtime environment for Android 5.0 and above.
[0035] like Figure 1 As shown, an exemplary startup process of an Android operating system is shown, and the startup process includes the following steps.
[0036] Step 110: Turn on the power and the system starts.
[0037] When the power is pressed, the code of the boot chip starts to execute from the predefined location of ROM (Read-Only Memory). The BootLoader is loaded into RAM (Random Access Memory).
[0038] Step 111: Start the BootLoader (boot program).
[0039] The BootLoader (boot program) pulls up the system OS (Operating System) and runs it. Optionally, the BootLoader (boot program) pulls up the kernel of the operating system and starts running it.
[0040] Step 112: The Linux kernel starts.
[0041] When the kernel starts, it sets up cache, protected memory, schedule list, and loads drivers. After the kernel completes the system settings, it first searches for the init.rc file (initialization file) in the system files and starts the init process.
[0042] Step 113: The init process starts.
[0043] 1) Create and mount the file directories required for startup.
[0044] 2) Initialize and start attribute services.
[0045] 3) Parse the init.rc configuration file and start the Zygote (incubator) process.
[0046] The init process is the first process in the user space of the Android system, and its process number is 1. After the kernel completes the system settings, it first searches for the init.rc file in the system files, starts the init process, and executes the main (entry function) of the init process. The init.rc configuration file is a script written in the Android Init Language.
[0047] Step 114: The Zygote (incubator) process starts.
[0048] 1) Create AppRuntime (application runtime environment) and call its start method to start the Zygote (incubator) process.
[0049] 2) Create a Java virtual machine and register JNI (Java Native Interface) methods for the Java virtual machine.
[0050] 3) Call the main method of ZygoteInit (incubator initialization) through JNI to enter the Java framework of Zygote.
[0051] 4) Create a server-side Socket through the registerZygoteSocket method, and wait for the AMS request through the runSelectLoop method to create a new application process.
[0052] 5) Start the SystemServer (system service) process.
[0053] In the Android system, DVM, ART, application process and SystemServer process are all created by the Zygote process.
[0054] Step 115: The SystemServer process starts.
[0055] 1) Start the Binder thread pool.
[0056] 2) Create SystemServiceManager (system service management).
[0057] 3) Start various system services (AMS, PMS (Package Manager Service, Package Management Service)...).
[0058] The SystemServer process is mainly used to create system services.
[0059] Step 116: AMS starts the Launcher process.
[0060] 1) Obtain APP (Application) information through PMS and display the APP icon on the interface.
[0061] When the SystemServer process is started, it will start AMS and PMS in turn. After PMS is started, it will install the applications in the system. Then AMS will start the Launcher process. The entry point of the Launcher process is the systemReady method of AMS, which is called in the startOtherServices method of SystemServer.java.
[0062] like Figure 2 The figure shows an exemplary startup process of an Android application.
[0063] When the user clicks the icon, the startProcessLocked method of AMS is called to send a process creation request to the Zygote (incubator) process 121 to request the creation of an application process.
[0064] After the Zygote process receives the request, it starts to create the application process. After the Zygote process is started, the runSelectLoop method of the ZygoteServer (incubator service) object is called, and the loop waits for the request from the AMS. At this time, the startup parameters saved in the ArrayList (array list) are written to the ZygoteState (incubator state) object through the zygoteSendArgsAndGetResult (incubator sends parameters and gets results) method. The Zygote process will receive a request to create a new application. When the Zygote process receives a request to create a new application, the runOnce (run once) method of the corresponding ZygoteConnection (incubator connection) object is called in the runSelectLoop method.
[0065] Figure 3 A schematic diagram of a terminal provided by an exemplary embodiment of the present application is shown.
[0066] Exemplarily, the memory management method of the application shown in the embodiment of the present application can be applied in a terminal, and the terminal 101 is installed with an Android operating system. The terminal may include a mobile phone, a tablet computer, a notebook computer, a laptop computer, a desktop computer, an all-in-one computer, an Internet of Things device, an intelligent robot workstation, a television, a set-top box, smart glasses, a smart watch, a digital camera, an MP4 player terminal, an MP5 player terminal, a learning machine, a point-reading machine, an electronic paper book, an electronic dictionary, a vehicle terminal, a virtual reality (English: Virtual Reality, abbreviated: VR) player terminal or an augmented reality (English: Augmented Reality, abbreviated: AR) player terminal, etc.
[0067] Exemplarily, a memory management program 102 is installed on the terminal 101. When the memory management function of an application needs to be used, the terminal can run the memory management program to execute the memory management method of the application.
[0068] The terminal 101 includes a first memory and a first processor. The first memory stores a memory management algorithm of an application program; the memory management algorithm of the above application program is called and executed by the first processor to implement the memory management method of the application program provided in the present application. The first memory may include but is not limited to the following: random access memory (Random Access Memory, RAM), read only memory (Read Only Memory, ROM), programmable read-only memory (Programmable Read-Only Memory, PROM), erasable read-only memory (Erasable Programmable Read-Only Memory, EPROM), and electrically erasable read-only memory (Electric Erasable Programmable Read-Only Memory, EEPROM).
[0069] The first processor may be composed of one or more integrated circuit chips. Optionally, the first processor may be a general-purpose processor, such as a central processing unit (CPU) or a network processor (NP). Optionally, the first processor may implement the memory management method of the application provided in the present application by running a program or code.
[0070] Figure 4 1 is a flowchart of a memory management method for an application provided by an exemplary embodiment of the present application. The memory management method for the application can be applied in a terminal, which can be the above-mentioned Figure 3 The terminal shown. Figure 4In , the application's memory management methods include:
[0071] Step 210, storing a memory configuration file in an array container of the AMS; the memory configuration file includes: at least one application, and a memory preference configuration corresponding to at least one application; the at least one application includes a first application.
[0072] Optionally, an Android operating system and a memory management program are installed on the terminal. The method provided in the embodiment of the present application can be implemented by running the memory management program. Alternatively, the method provided in the embodiment of the present application can be executed by the Android operating system.
[0073] Optionally, during the boot phase, the memory configuration file is stored in an array container of the AMS.
[0074] For example, see Figure 1 The boot process of the Android operating system, when starting the AMS in the SystemServer process, reads the memory configuration file and stores it in the array container in the AMS. The array container can be an ArrayMap structure. Exemplarily, before booting, the memory configuration file can be stored in a non-volatile memory (NVM), for example, in a ROM (Read-Only Memory).
[0075] The memory configuration file stores a one-to-one correspondence between applications and memory preference configurations. The memory configuration file can be stored in the format of ($packageName, $typeId). For example, the memory configuration file can store at least one set of data in the format of (application name, memory preference configuration identifier). For example, the memory configuration file can store (first application, first memory preference configuration).
[0076] The memory preference configuration may be used to indicate a specific memory management policy (e.g., the application specifies the memory management policy). The memory preference configuration may also be used to indicate the priority of the memory management policy (e.g., the priority corresponding to a memory management policy, or the priorities corresponding to multiple memory management policies). The memory preference configuration may also be used to indicate the order of the memory management policies (e.g., the order of multiple memory management policies).
[0077] Exemplarily, the memory management strategy may include at least one of the following GC strategies: copy collection strategy, mark-compact strategy, Mark-sweep strategy, Generational strategy, Concurrent strategy, Incremental strategy. And / or, the memory management strategy may also include at least one of the following memory allocation strategies: First-fit, Best-fit, Worst-fit, Next-fit, Quick-fit. And / or, the memory management strategy may be a customized new memory management strategy. And / or, the memory management strategy may be a new memory management strategy obtained by combining at least two of the above memory management strategies.
[0078] Copy collection strategy: used to solve the problem of memory fragmentation. This strategy divides the heap memory into two parts: an active space (from-space) and a free space (to-space). When the collector runs, it first scans and marks all active objects. Then, it copies all surviving objects from the active space to the free space, discards all uncopied objects, and makes the free space the new active space. In this way, objects that are not referenced are cleaned up, and all surviving objects in memory are placed together continuously. Since this strategy copies all surviving objects and places them continuously, the problem of memory fragmentation can be avoided. In addition, since only active objects need to be scanned and copied, the time overhead of copy collection is smaller than that of other GC strategies. The disadvantage of the copy collection strategy is that additional space is required to save the copied objects, and some or all of the objects need to be copied every time garbage collection is performed, which may cause performance overhead. Therefore, it is usually used for garbage collection of the new generation, because the life cycle of the new generation objects is short, so the copy overhead is relatively small. In summary, the copy collection strategy maintains the continuity of memory and reduces the generation of fragmentation by copying surviving objects.
[0079] Mark-compact strategy: used to solve the problem of memory fragmentation. In the Mark-compact strategy, the collector first scans and marks all active objects, then performs memory compaction operations, moves all active objects to one end of the memory, and then updates the relationship between objects by adjusting pointers and updating references. In this way, all active objects are placed consecutively, and the original free space is cleared. Unlike the Copy collection strategy, the Mark-compact strategy does not require additional space to save copied objects. Instead, it performs memory compaction by moving the position of objects. This ensures the continuity of memory and reduces the generation of fragmentation. The disadvantage of the Mark-compact strategy is that the position and reference of objects need to be moved and updated during the compaction phase, which may bring certain performance overhead. In summary, the Mark-compact strategy maintains the continuity of memory and reduces the generation of fragmentation by arranging the positions of surviving objects.
[0080] Generational strategy: Since most objects have a short life cycle, they will soon become garbage. Therefore, the Generational strategy divides the memory into multiple "generations", generally divided into two or three generations. The first generation (usually called the young generation) is the area for storing newly created objects, and the second generation and subsequent generations are the areas for storing objects with relatively long survival times. The basic assumption of the Generational strategy is that there are a large number of transient objects in memory, and few objects will survive for a long time. Therefore, this strategy improves the efficiency of garbage collection by regularly collecting garbage in the young generation. When an object survives for a period of time, it will be moved to the next generation. Older generations will be garbage collected at a lower frequency because there will be less garbage to be collected in these generations. By using the Generational strategy, the collector can manage memory more efficiently and reduce the overhead of garbage collection.
[0081] Concurrent strategy: Unlike the traditional paused garbage collection strategy (which requires stopping the application execution during garbage collection), the Concurrent strategy allows the application execution to continue while garbage collection is in progress to reduce the impact on application performance. The goal of the Concurrent strategy is to recycle as much garbage as possible while keeping the program running. It achieves this goal by running the collector concurrently, that is, while the application continues to execute, the collector also runs in the background to recycle useless memory. Concurrent garbage collectors usually use some techniques to achieve concurrent execution, such as concurrent marking and concurrent cleaning. In the concurrent marking phase, the collector marks all reachable objects, during which the application can continue to execute. In the concurrent cleaning phase, the collector recycles objects that have been marked as garbage and releases the memory they occupy. By using the Concurrent strategy, the collector can better execute concurrently with the application, reducing the time the application pauses and improving the system's responsiveness. However, the implementation of the Concurrent strategy is more complex and requires handling issues such as concurrent access and data synchronization. Therefore, the Concurrent strategy is usually used in large applications and scenarios that require higher performance.
[0082] Incremental strategy: Unlike the one-time full garbage collection strategy, the Incremental strategy breaks down the garbage collection process into multiple small steps and alternates them with the execution of the application. In the Incremental strategy, the collector divides the garbage collection process into multiple stages and inserts the execution of the application between each stage. For example, in the incremental marking phase, the collector marks all reachable objects and executes alternately with the application during the marking process. Similarly, in the incremental clearing phase, the collector reclaims objects marked as garbage and releases memory. By using the Incremental strategy, the execution of the application and the collection process are performed alternately, thereby reducing the long pauses caused by a single full garbage collection. This strategy can improve the responsiveness of the system and reduce the user's perception of system pauses. However, the implementation of the Incremental strategy is more complicated, and it is necessary to deal with the data consistency issues between the incremental phase and the application, as well as the efficiency issues of incremental collection. Therefore, the Incremental strategy is usually used in scenarios that require higher responsiveness and is combined with other GC strategies, such as the Generational strategy and the Concurrent strategy, to achieve better results.
[0083] First-fit algorithm: Start searching from the beginning of the free memory block list and select the first free memory block that meets the memory size requirement to meet the memory demand.
[0084] Best-fit algorithm: Select the smallest memory block that is large enough to meet the memory requirements from all free memory blocks.
[0085] Worst-fit algorithm: Select the largest memory block from all free memory blocks to meet the memory demand. This algorithm is mainly used for large memory requests in order to leave larger free memory blocks.
[0086] Next-fit algorithm: Start searching from the last allocated location, select the first free memory block that meets the memory size requirement, and continue searching backwards.
[0087] Quick-fit algorithm: Divide the memory into fixed-size blocks, each of which has a linked list of free memory blocks. When a request is made to allocate memory, a block of the appropriate size is quickly selected based on the memory requirements.
[0088] Exemplarily, the memory preference configuration may be set for the application according to the memory usage preference of the application. The memory preference of the application may include at least one of the following: small memory prone to fragmentation usage preference, utilization preference, efficiency preference, scalability preference, low power preference, security preference, data protection preference, fast startup preference, and reliability preference.
[0089] Small memory is prone to fragmentation usage preference: refers to the situation in memory management where the allocation and release of small memory spaces may more easily lead to memory fragmentation problems. Memory fragmentation refers to the existence of unused memory blocks in the memory space in a scattered and discontinuous manner. When a program frequently allocates and releases small memory blocks, many small and scattered free memories may be left in the memory. For example, a small memory space can refer to a memory space less than 100KB (kilobytes).
[0090] Utilization preference: refers to the selection and allocation of available memory blocks in memory management. The system prefers to use memory blocks with higher memory utilization. Memory utilization refers to the ratio between memory usage and total memory. Generally, high memory utilization means that memory is used more fully and efficiently.
[0091] Efficiency preference: refers to the system's preference to use more efficient memory allocation algorithms or strategies in memory management. In memory management, efficiency refers to the time and resources required by the system to allocate and release memory. The goal of efficiency preference is to improve the execution speed of memory management and resource utilization efficiency.
[0092] Scalability preference: Some applications need to be able to scale effectively to handle larger data and loads, so the use of memory needs to be well scalable.
[0093] Low power preference: For applications running on low-power devices, such as mobile devices or IoT devices, optimizing memory usage can reduce energy consumption and extend battery life.
[0094] Security preference: Some applications need to consider memory safety to avoid vulnerabilities such as memory overflow and buffer overflow to ensure the security of the application.
[0095] Data protection preference: For applications that process sensitive data, appropriate memory protection measures need to be taken to prevent data leakage or illegal access.
[0096] Fast startup preference: Some applications need to start quickly, so the use of memory needs to take into account preloading or preheating mechanisms to speed up the startup of applications.
[0097] Reliability preference: For critical applications or services, you need to ensure the reliability of memory and avoid memory errors or crashes to maintain the stability and reliability of the application.
[0098] For applications with different memory preferences, targeted memory management policies can be set. For example, when the memory usage preference of the first application is a small memory and easy fragmentation usage preference, the first memory preference configuration includes a copy collection policy with a high priority; the copy collection policy is used to copy live objects to free space to clear unreferenced objects; when the memory usage preference of the first application is a utilization preference, the first memory preference configuration includes a mark-and-sweep policy with a high priority; the mark-and-sweep policy is used to mark active objects and perform memory tidying on active objects; when the memory usage preference of the first application is an efficiency preference, the first memory preference configuration includes a mark-and-sweep policy with a high priority; the mark-and-sweep policy is used to clear unmarked objects and reclaim memory occupied by unmarked objects.
[0099] Step 220: During the application startup phase of the first application, the first memory preference configuration corresponding to the first application is transferred to the ART virtual machine through the AMS.
[0100] Exemplarily, when the first application is cold-started and the boot process is transferred to AMS, AMS determines whether the application package name of the first application is included in the memory configuration file. If included, the first memory preference configuration of the first application is passed to the ART virtual machine and saved. The relevant interfaces of the recycler and allocator in the ART virtual machine determine the first memory preference configuration and adjust the priority order of memory allocation and recycling strategies.
[0101] Step 230: Adjust the memory management policy of the first application based on the first memory preference configuration through the ART virtual machine.
[0102] The first application will run on the ART virtual machine, and the ART virtual machine can manage memory allocation and memory recovery of the first application according to a first memory preference configuration corresponding to the first application.
[0103] In summary, the memory management method for applications provided in this embodiment pre-stores the memory preference configurations of various applications in the array container of AMS. During the startup phase of the application, when the startup process is executed to AMS, AMS can read the memory preference configuration corresponding to the application from the pre-stored memory configuration file, and transfer the memory preference configuration to the ART virtual machine. When the ART virtual machine runs the application, it can set the memory management policy of the application according to the memory preference configuration, so that different applications adopt different memory management policies, and the memory management policy is configured for each application in a targeted manner, thereby improving the memory management efficiency and accuracy of the application.
[0104] Exemplarily, an embodiment of transferring a memory preference configuration to an ART virtual machine and applying the memory preference configuration to manage an application is provided.
[0105] Figure 5 is a flow chart of a memory management method for an application provided by another exemplary embodiment of the present application. The memory management method for the application can be applied in a terminal, which can be the above-mentioned Figure 3 The terminal shown. Based on Figure 4 In the illustrated embodiment, step 220 includes step 221 and step 222 .
[0106] Step 210, storing a memory configuration file in an array container of the AMS; the memory configuration file includes: at least one application, and a memory preference configuration corresponding to at least one application; the at least one application includes a first application.
[0107] For example, Figure 6 As shown, during the boot phase, the terminal reads the memory configuration file 120 into the AMS for storage; during the application cold start phase, the terminal transfers the memory preferences stored in the AMS to the ART virtual machine.
[0108] Exemplarily, a memory profile may also be referred to as a “profile”, a “memory preference profile”, a “memory management profile”, etc.
[0109] Memory preference configuration may also be referred to as "memory preference", "memory preference parameters", "memory management preference", etc.
[0110] Step 221, during the application startup phase of the first application, a process creation request is sent to the incubator by calling the first function of the AMS, where the first function is used to send the process creation request, and the process creation request includes indication information of the first memory preference configuration corresponding to the first application; the incubator is used to copy the incubator process to obtain a new process for use by the first application.
[0111] Exemplarily, during the application startup phase of the first application, the first application is queried in the memory configuration file through AMS; when the memory configuration file contains the first application, the first memory preference configuration corresponding to the first application is read from the memory configuration file through AMS.
[0112] Zygote (incubator) is an important concept in the Android operating system. It is a special process used to provide a preloaded system state when an application starts. In the Android operating system, every time a new application is started, many system classes and resources need to be loaded and initialized, which consumes a certain amount of time and memory. In order to reduce this overhead, the Android operating system introduced the Zygote process. The Zygote process is created when the system starts, and it preloads and initializes many commonly used system classes and resources. When a new application needs to be started, the Android operating system copies the memory space of the Zygote process and then runs the application's code in it. In this way, the application can start from an already initialized state without having to load and initialize system classes and resources again, thereby speeding up the startup of the application. The Zygote process generates processes for new applications. These new processes inherit the memory state of the Zygote process when they are generated, thus avoiding repeated initialization processes. At the same time, the Zygote process also starts and manages an application's virtual machine instance (such as the ART virtual machine) to execute the application's code.
[0113] Exemplarily, the first function may be startProcessLocked (start process locked).
[0114] Step 222: Create a first process for the first application program through the incubator, and initialize the ART virtual machine in the first process according to the first memory preference configuration.
[0115] Exemplarily, the process creation request includes a runtime flag (runtimeFlags), and the runtime flag includes indication information of the first memory preference configuration; the terminal initializes the ART virtual machine in the first process according to the runtime flag through the incubator. The runtime flag is used to configure the ART virtual machine.
[0116] Exemplarily, the terminal calls the second function of the incubator to intercept the first memory preference configuration in the running environment tag, and sets the ART virtual machine in the first process according to the first memory preference configuration; the second function is used to perform preprocessing of the ART virtual machine initialization.
[0117] Exemplarily, through the ART virtual machine, a third function is called to set the GC policy of the first application according to the first memory preference configuration, and the third function is used to set compiler options.
[0118] Exemplarily, after the startup process of the first application reaches startProcessLocked (the startup process is locked), there is a runtimeFlags (running environment label / runtime label / runtime environment label) label assignment process in the startProcessLocked process of the startup process corresponding to ProcessList (process list). Here, the application information of the first application is matched to see whether it is included in the array structure (memory configuration file) of the AMS startup phase. If it is included, the label is assigned to runtimeFlags. Thereafter, when the process is associated with zygote (incubator) through process (process), the corresponding runtimeFlags will be passed to the ART virtual machine.
[0119] Exemplarily, the second function may be dalvik_system_ZygoteHooks (dalvik_system_incubator hook); the third function may be AddCompilerOption (application compiler option). runtimeFlags can be intercepted and set accordingly in dalvik_system_ZygoteHooks (dalvik_system_incubator hook). The specific operation interface is in ZygoteHooks_nativePostForkChild. For the specific ART priority preference implementation, AddCompilerOption (application compiler option) is used to execute the compilation option to adjust the GC preference. The corresponding parameters can use the built-in -Xgc and -XX:BackgroundGC or customize similar parameters. ParsedOptions (analysis options) parses the corresponding parameters and then selects the corresponding allocator and collector preferences.
[0120] For example, Figure 7 As shown, the terminal executes step 301: queries whether the first application is in the memory configuration file through AMS. If the memory configuration file contains the first application, then execute step 302: AMS writes the memory preference configuration corresponding to the first application into the runtime environment tag (runtimeFlags). If the memory configuration file does not contain the first application, then execute step 303: execute the relevant process of process startup normally.
[0121] Step 230: Adjust the memory management policy of the first application based on the first memory preference configuration through the ART virtual machine.
[0122] For example, Figure 8 As shown, when running the first application, the terminal executes step 401: determining whether the first application corresponds to a memory preference configuration. If there is no corresponding memory preference configuration, step 402 is executed: calling a compilation instruction to run the native memory management policy. If there is a corresponding first memory preference configuration, step 403 is executed: calling a compilation instruction to run the memory management policy corresponding to the first memory preference configuration. For example, the native memory management policy can be a memory management policy pre-specified in the Android operating system.
[0123] In summary, the memory management method for applications provided in this embodiment can set different memory preference configurations for various applications. For example, for applications that prefer small memory and easy fragmentation, the copycollection policy priority can be increased, for applications that prefer utilization, the mark compact policy priority can be increased, and for applications that prefer efficiency, the mark-swap policy priority can be increased. The implementation of this solution can improve the fit between applications and memory policies in a targeted manner, thereby improving the efficiency of art memory usage.
[0124] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0125] Please refer to Fig. 9 , Fig. 9 This is a structural block diagram of a memory management device for an application provided by an exemplary embodiment of the present application. The memory management device for the application can be implemented as all or part of the terminal through software, hardware, or a combination of both. The device includes:
[0126] The system service module 501 is used to store a memory configuration file in an array container of the activity management service AMS; the memory configuration file includes: at least one application program, and memory preference configurations respectively corresponding to the at least one application program; the at least one application program includes a first application program;
[0127] The system service module 501 is used to transfer the first memory preference configuration corresponding to the first application to the Android operating environment ART virtual machine through the AMS during the application startup phase of the first application;
[0128] The application module 502 is used to adjust the memory management policy of the first application based on the first memory preference configuration through the ART virtual machine.
[0129] In an optional embodiment, the device further includes:
[0130] The system service module 501 is used to send a process creation request to the incubator by calling a first function of the AMS, wherein the first function is used to send the process creation request, and the process creation request includes indication information of the first memory preference configuration corresponding to the first application; the incubator is used to copy the incubator process to obtain a new process for use by the first application;
[0131] The incubator module 503 is used to create a first process for the first application through the incubator, and initialize the ART virtual machine in the first process according to the first memory preference configuration.
[0132] In an optional embodiment, the process creation request includes an operating environment tag, and the operating environment tag includes indication information of the first memory preference configuration;
[0133] The incubator module 503 is used to initialize the ART virtual machine in the first process according to the operating environment label.
[0134] In an optional embodiment, the incubator module 503 is used to call the second function of the incubator to intercept the first memory preference configuration in the operating environment label, and set the ART virtual machine in the first process according to the first memory preference configuration; the second function is used to perform preprocessing of the ART virtual machine initialization.
[0135] In an optional embodiment, the incubator module 503 is used to call a third function through the ART virtual machine to set the garbage collection GC policy of the first application according to the first memory preference configuration, and the third function is used to set compiler options.
[0136] In an optional embodiment, the system service module 501 is used to query the first application in the memory configuration file through the AMS during the application startup phase of the first application;
[0137] The system service module 501 is configured to read the first memory preference configuration corresponding to the first application from the memory configuration file through the AMS when the memory configuration file includes the first application.
[0138] In an optional embodiment, in the case where the memory usage preference of the first application is a small memory and easy memory fragmentation usage preference, the first memory preference configuration includes a copy collection strategy having a high priority; the copy collection strategy is used to copy surviving objects to free space to clear unreferenced objects;
[0139] In the case where the memory usage preference of the first application is a utilization preference, the first memory preference configuration includes that a mark-and-tidy strategy has a high priority; the mark-and-tidy strategy is used to mark active objects and perform memory tidying on the active objects;
[0140] In the case where the memory usage preference of the first application is an efficiency preference, the first memory preference configuration includes a mark-and-sweep policy having a high priority; the mark-and-sweep policy is used to clear unmarked objects and reclaim memory occupied by the unmarked objects.
[0141] It should be noted that: the memory management device for an application provided in the above embodiment only uses the division of the above functional modules as an example when executing the memory management method for an application. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the memory management device for an application provided in the above embodiment and the embodiment of the memory management method for an application belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0142] The present application also provides a terminal, which includes a processor and a memory, wherein the memory stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the memory management method of the application provided by each of the above method embodiments. It should be noted that the terminal can be as follows Fig.10 The terminal provided.
[0143] Fig.10 The structure block diagram of a terminal 1000 provided by an exemplary embodiment of the present application is shown. The terminal 1000 may be: a smart phone, a tablet computer, an MP3 player (Moving Picture Experts Group Audio Layer III, Moving Picture Experts Group Audio Layer 3), an MP4 (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Group Audio Layer 4) player, a laptop computer or a desktop computer. The terminal 1000 may also be called a user account device, a portable terminal, a laptop terminal, a desktop terminal or other names.
[0144] Typically, the terminal 1000 includes a processor 1001 and a memory 1002 .
[0145] The processor 1001 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1001 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 1001 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 1001 may be integrated with a GPU (Graphics Processing Unit, a memory manager for applications), and the GPU is responsible for rendering and drawing the content that needs to be displayed on the display screen. In some embodiments, the processor 1001 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0146] The memory 1002 may include one or more computer-readable storage media, which may be non-transitory. The memory 1002 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1002 is used to store at least one instruction, which is used to be executed by the processor 1001 to implement the memory management method of the application provided in the method embodiment of the present application.
[0147] In some embodiments, the terminal 1000 may further optionally include: a peripheral device interface 1003 and at least one peripheral device. The processor 1001, the memory 1002 and the peripheral device interface 1003 may be connected via a bus or a signal line. Each peripheral device may be connected to the peripheral device interface 1003 via a bus, a signal line or a circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 1004, a display screen 1005, a camera assembly 1006, an audio circuit 1007, and a power supply 1009.
[0148] The peripheral device interface 1003 may be used to connect at least one peripheral device related to I / O (Input / Output) to the processor 1001 and the memory 1002. In some embodiments, the processor 1001, the memory 1002, and the peripheral device interface 1003 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1001, the memory 1002, and the peripheral device interface 1003 may be implemented on a separate chip or circuit board, which is not limited in this embodiment.
[0149] The radio frequency circuit 1004 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 1004 communicates with the communication network and other communication devices through electromagnetic signals. The radio frequency circuit 1004 converts the electrical signal into an electromagnetic signal for transmission, or converts the received electromagnetic signal into an electrical signal. Exemplarily, the radio frequency circuit 1004 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user account identity module card, and the like. The radio frequency circuit 1004 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes, but is not limited to: the World Wide Web, a metropolitan area network, an intranet, various generations of mobile communication networks (2G, 3G, 4G and 5G), a wireless local area network and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 1004 may also include circuits related to NFC (Near Field Communication), which is not limited in this application.
[0150] The display screen 1005 is used to display a UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 1005 is a touch display screen, the display screen 1005 also has the ability to collect touch signals on the surface or above the surface of the display screen 1005. The touch signal can be input to the processor 1001 as a control signal for processing. At this time, the display screen 1005 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, the display screen 1005 can be one, and the front panel of the terminal 1000 is set; in other embodiments, the display screen 1005 can be at least two, which are respectively set on different surfaces of the terminal 1000 or are folded; in some other embodiments, the display screen 1005 can be a flexible display screen, which is set on the curved surface or folded surface of the terminal 1000. Even, the display screen 1005 can also be set to a non-rectangular irregular shape, that is, a special-shaped screen. The display screen 1005 can be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).
[0151] The camera assembly 1006 is used to capture images or videos. Exemplarily, the camera assembly 1006 includes a front camera and a rear camera. Typically, the front camera is arranged on the front panel of the terminal, and the rear camera is arranged on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize the panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments, the camera assembly 1006 may also include a flash. The flash can be a monochrome temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.
[0152] The audio circuit 1007 may include a microphone and a speaker. The microphone is used to collect sound waves from the user account and the environment, and convert the sound waves into electrical signals and input them into the processor 1001 for processing, or input them into the radio frequency circuit 1004 to achieve voice communication. For the purpose of stereo acquisition or noise reduction, there may be multiple microphones, which are respectively arranged at different parts of the terminal 1000. The microphone may also be an array microphone or an omnidirectional acquisition microphone. The speaker is used to convert the electrical signal from the processor 1001 or the radio frequency circuit 1004 into sound waves. The speaker may be a traditional film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert the electrical signal into sound waves audible to humans, but also convert the electrical signal into sound waves inaudible to humans for purposes such as ranging. In some embodiments, the audio circuit 1007 may also include a headphone jack.
[0153] The power supply 1009 is used to power various components in the terminal 1000. The power supply 1009 can be an alternating current, a direct current, a disposable battery, or a rechargeable battery. When the power supply 1009 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery charged through a wired line, and a wireless rechargeable battery is a battery charged through a wireless coil. The rechargeable battery can also be used to support fast charging technology.
[0154] In some embodiments, the terminal 1000 further includes one or more sensors 1010 . The one or more sensors 1010 include, but are not limited to: an acceleration sensor 1011 , a gyroscope sensor 1012 , a pressure sensor 1013 , an optical sensor 1015 , and a proximity sensor 1016 .
[0155] The acceleration sensor 1011 can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established by the terminal 1000. For example, the acceleration sensor 1011 can be used to detect the components of gravity acceleration on the three coordinate axes. The processor 1001 can control the display screen 1005 to display the user interface in a horizontal view or a vertical view according to the gravity acceleration signal collected by the acceleration sensor 1011. The acceleration sensor 1011 can also be used to collect motion data of games or user accounts.
[0156] The gyro sensor 1012 can detect the body direction and rotation angle of the terminal 1000, and the gyro sensor 1012 can cooperate with the acceleration sensor 1011 to collect the 3D actions of the user account on the terminal 1000. The processor 1001 can implement the following functions based on the data collected by the gyro sensor 1012: motion sensing (such as changing the UI according to the tilt operation of the user account), image stabilization during shooting, game control, and inertial navigation.
[0157] The pressure sensor 1013 can be set on the side frame of the terminal 1000 and / or the lower layer of the display screen 1005. When the pressure sensor 1013 is set on the side frame of the terminal 1000, the holding signal of the user account on the terminal 1000 can be detected, and the processor 1001 performs left and right hand recognition or shortcut operations according to the holding signal collected by the pressure sensor 1013. When the pressure sensor 1013 is set on the lower layer of the display screen 1005, the processor 1001 controls the operability controls on the UI interface according to the pressure operation of the user account on the display screen 1005. The operability controls include at least one of a button control, a scroll bar control, an icon control, and a menu control.
[0158] The optical sensor 1015 is used to collect the ambient light intensity. In one embodiment, the processor 1001 can control the display brightness of the display screen 1005 according to the ambient light intensity collected by the optical sensor 1015. Specifically, when the ambient light intensity is high, the display brightness of the display screen 1005 is increased; when the ambient light intensity is low, the display brightness of the display screen 1005 is reduced. In another embodiment, the processor 1001 can also dynamically adjust the shooting parameters of the camera assembly 1006 according to the ambient light intensity collected by the optical sensor 1015.
[0159] The proximity sensor 1016, also called a distance sensor, is usually arranged on the front panel of the terminal 1000. The proximity sensor 1016 is used to collect the distance between the user account and the front of the terminal 1000. In one embodiment, when the proximity sensor 1016 detects that the distance between the user account and the front of the terminal 1000 is gradually decreasing, the processor 1001 controls the display screen 1005 to switch from the screen-on state to the screen-off state; when the proximity sensor 1016 detects that the distance between the user account and the front of the terminal 1000 is gradually increasing, the processor 1001 controls the display screen 1005 to switch from the screen-off state to the screen-on state.
[0160] Those skilled in the art will understand that Fig.10 The structure shown in the figure does not constitute a limitation on the terminal 1000, and the terminal 1000 may include more or less components than those shown in the figure, or combine some components, or adopt a different component arrangement.
[0161] The memory also includes one or more programs, which are stored in the memory, and the one or more programs include a memory management method for executing the application provided in the embodiment of the present application.
[0162] The present application also provides a computer device, which includes: a processor and a memory, wherein the storage medium stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, at least one program, a code set or an instruction set is loaded and executed by the processor to implement the memory management method of the application provided in the above-mentioned method embodiments.
[0163] The present application also provides a computer-readable storage medium, which stores at least one instruction, at least one program, code set or instruction set. The at least one instruction, at least one program, code set or instruction set is loaded and executed by a processor to implement the memory management method of the application provided by the above-mentioned method embodiments.
[0164] The present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the memory management method of the application provided in the above optional implementation.
[0165] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0166] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0167] The above description is only an illustrative embodiment that can be implemented in the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application.
[0168] It should be noted that before collecting relevant data of users and during the process of collecting relevant data of users, this application can display a prompt interface, pop-up window or output voice prompt information, and the prompt interface, pop-up window or voice prompt information is used to prompt the user that its relevant data is currently being collected, so that this application only starts to execute the relevant steps of obtaining relevant data of users after obtaining the confirmation operation issued by the user to the prompt interface or pop-up window, otherwise (that is, when the confirmation operation issued by the user to the prompt interface or pop-up window is not obtained), the relevant steps of obtaining relevant data of users are terminated, that is, the relevant data of users are not obtained. In other words, all user data collected by this application are collected with the consent and authorization of the user, and the collection, use and processing of relevant user data need to comply with the relevant laws, regulations and standards of relevant countries and regions.
Claims
1. A memory management method for an application, characterized in that: The method is executed by a terminal, and includes: Storing a memory configuration file in an array container of an activity management service AMS; the memory configuration file includes: at least one application program, and memory preference configurations corresponding to the at least one application program; the at least one application program includes a first application program; During the application startup phase of the first application, the first memory preference configuration corresponding to the first application is transmitted to the Android operating environment ART virtual machine through the AMS; The memory management policy of the first application is adjusted based on the first memory preference configuration by the ART virtual machine.
2. The method according to claim 1, characterized in that The step of transferring the first memory preference configuration corresponding to the first application to the Android operating environment ART virtual machine through the AMS includes: Sending a process creation request to the incubator by calling a first function of the AMS, wherein the first function is used to send the process creation request, and the process creation request includes indication information of the first memory preference configuration corresponding to the first application; the incubator is used to copy the incubator process to obtain a new process for use by the first application; A first process is created for the first application through the incubator, and the ART virtual machine in the first process is initialized according to the first memory preference configuration.
3. The method according to claim 2, characterized in that The process creation request includes an operating environment tag, and the operating environment tag includes indication information of the first memory preference configuration; Initializing the ART virtual machine in the first process according to the first memory preference configuration includes: Initialize the ART virtual machine in the first process according to the operating environment label.
4. The method according to claim 3, characterized in that Initializing the ART virtual machine in the first process according to the operating environment label includes: The second function of the incubator is called to intercept the first memory preference configuration in the operating environment tag, and set the ART virtual machine in the first process according to the first memory preference configuration; the second function is used to perform preprocessing of initialization of the ART virtual machine.
5. The method according to claim 4, characterized in that The adjusting the memory management policy of the first application based on the first memory preference configuration by the ART virtual machine includes: Through the ART virtual machine, a third function is called to set the garbage collection GC policy of the first application according to the first memory preference configuration, and the third function is used to set compiler options.
6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: In an application startup phase of the first application, querying the first application in the memory configuration file through the AMS; In a case where the memory configuration file includes the first application, the first memory preference configuration corresponding to the first application is read from the memory configuration file by the AMS.
7. The method according to any one of claims 1 to 5, characterized in that: In the case where the memory usage preference of the first application is a fragmented memory usage preference, the first memory preference configuration includes a copy collection strategy having a high priority; the copy collection strategy is used to copy surviving objects to free space to clear unreferenced objects; In a case where the memory usage preference of the first application is a utilization preference, the first memory preference configuration includes marking the cleanup strategy as having a high priority; The mark-and-arrange strategy is used to mark active objects and perform memory arrangement on the active objects; In the case where the memory usage preference of the first application is an efficiency preference, the first memory preference configuration includes a mark-and-sweep policy having a high priority; the mark-and-sweep policy is used to clear unmarked objects and reclaim memory occupied by the unmarked objects.
8. A memory management device for an application, characterized in that: The device comprises: A system service module, configured to store a memory configuration file in an array container of an activity management service AMS; the memory configuration file includes: at least one application program, and memory preference configurations respectively corresponding to the at least one application program; the at least one application program includes a first application program; The system service module is used to transfer the first memory preference configuration corresponding to the first application to the Android operating environment ART virtual machine through the AMS during the application startup phase of the first application; An application module is used to adjust the memory management policy of the first application based on the first memory preference configuration through the ART virtual machine.
9. A terminal, characterized in that: The terminal includes a processor, a memory connected to the processor, and program instructions stored in the memory. When the processor executes the program instructions, the memory management method of the application program according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, wherein program instructions are stored in the storage medium, characterized in that: When the program instructions are executed by a processor, the memory management method of the application program as described in any one of claims 1 to 7 is implemented.