Memory management method and apparatus, electronic device, and readable storage medium

By determining the recycling priority and performing memory recycling processing based on information related to component attributes, the problem of insufficient memory of electronic equipment is solved, and the operating performance and memory recycling efficiency are improved.

WO2024222605A1PCT designated stage expired Publication Date: 2024-10-31VIVO MOBILE COMM CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/089014
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-04-27
Filing Date
2024-04-22
Publication Date
2024-10-31

AI Technical Summary

Technical Problem

When electronic devices start up or switch pages, they need to quickly allocate a large amount of memory, resulting in insufficient memory and thus affecting operating performance.

Method used

Determine the recycling priority based on the component's attribute-related information, and perform memory recycling processing to optimize the use of system memory.

Benefits of technology

Memory recycling is performed on a component-by-component basis, which improves the flexibility and efficiency of memory recycling, avoids processes being scanned and killed, ensures process keep-alive, reduces memory recycling time, and improves device operating performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024089014_31102024_PF_FP_ABST
    Figure CN2024089014_31102024_PF_FP_ABST
Patent Text Reader

Abstract

Provided are a memory management method and apparatus, an electronic device, and a readable storage medium. The method comprises: according to attribute-related information of N components, determining N reclamation priorities in one-to-one correspondence to the N components; and according to the N reclamation priorities, performing memory reclamation processing on M components among the N components, wherein N and M are positive integers, and M is less than or equal to N.
Need to check novelty before this filing date? Find Prior Art

Description

Memory management method, device, electronic device and readable storage medium

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This application claims priority to Chinese patent application No. 202310476995.8 filed in China on April 27, 2023, the entire contents of which are incorporated herein by reference. Technical Field

[0003] The present application belongs to the field of communication technology, and specifically relates to a memory management method, device, electronic device and readable storage medium. Background Art

[0004] Currently, a large number of applications are installed on devices, and these applications have high requirements for the amount of memory required and the speed of memory allocation. For example, when many applications are launched or when switching pages, they will quickly allocate a large amount of memory, resulting in insufficient memory on the electronic device and poor performance.

[0005] Summary of the Invention

[0006] The purpose of the embodiments of the present application is to provide a memory management method, device, electronic device and readable storage medium, which can improve the operating performance of the electronic device.

[0007] In a first aspect, an embodiment of the present application provides a memory management method, which includes: determining N recycling priorities corresponding to the N components one by one based on attribute-related information of the N components, where the attribute-related information of the components is used to characterize the importance of the components; and performing memory recycling processing on M components out of the N components based on the N recycling priorities, where N and M are positive integers and M is less than or equal to N.

[0008] In a second aspect, an embodiment of the present application provides a memory management device, comprising: a determination module and a processing module. The determination module is configured to determine N recycling priorities corresponding to the N components based on attribute-related information of the N components, where the attribute-related information of the components is used to characterize the importance of the components; and the processing module is configured to perform memory recycling processing on M of the N components based on the N recycling priorities determined by the determination module, where N and M are positive integers and M is less than or equal to N.

[0009] In a third aspect, an embodiment of the present application provides an electronic device comprising a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the method described in the first aspect are implemented.

[0010] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.

[0011] In a fifth aspect, an embodiment of the present application provides a chip, which includes a processor and a communication interface, the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the method described in the first aspect.

[0012] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and executed by at least one processor to implement the method described in the first aspect.

[0013] In an embodiment of the present application, N recycling priorities corresponding to each of the N components can be determined based on information related to the properties of the N components, where the information related to the properties of the components is used to characterize the importance of the components; and based on the N recycling priorities, memory recycling processing is performed on M of the N components, where N and M are positive integers, and M is less than or equal to N. Through this solution, since N recycling priorities corresponding to each of the N components can be determined based on information related to the properties of the N components, and memory recycling processing is directly performed on the M of the N components based on the recycling priorities corresponding to the N components, the system memory of the electronic device, such as the operating memory, can be quickly restored, thereby improving and optimizing the operating performance of the electronic device. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] FIG1 is a schematic diagram of a memory management method according to an embodiment of the present invention;

[0015] FIG2 is a second schematic diagram of a memory management method according to an embodiment of the present application;

[0016] FIG3 is a third schematic diagram of a memory management method according to an embodiment of the present application;

[0017] FIG4 is a fourth schematic diagram of a memory management method provided in an embodiment of the present application;

[0018] FIG5 is a fifth schematic diagram of a memory management method provided in an embodiment of the present application;

[0019] FIG6 is a schematic diagram of the structure of a memory management device provided in an embodiment of the present application;

[0020] FIG7 is a schematic structural diagram of an electronic device provided in an embodiment of the present application;

[0021] FIG8 is a schematic diagram of the hardware structure of the electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0022] The following will be combined with the accompanying drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the embodiments described are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field are within the scope of protection of this application.

[0023] The terms "first," "second," and the like in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of this application can be implemented in an order other than that illustrated or described herein, and that the objects distinguished by "first," "second," and the like are generally of the same type, and do not limit the number of objects; for example, the first object can be one or more. In addition, the term "and / or" in the specification and claims refers to at least one of the connected objects, and the character " / " generally indicates that the objects connected are in an "or" relationship.

[0024] The following explains the nouns or terms related to the memory management method, device, electronic device and readable storage medium provided in the embodiments of the present application.

[0025] Memory: Here it refers to the running memory. The program needs to be loaded from the storage to the running memory during runtime so that it can be quickly called by the Central Processing Unit (CPU).

[0026] System memory: This refers to the running memory of electronic devices.

[0027] Process: A process is the basic unit of resource allocation and represents an instance of an application. On a device, all applications (APPs) are implemented by individual processes. An application contains multiple processes.

[0028] Component: The basic unit of a process. A process is made up of a number of discrete yet interconnected components. Different types of components carry out different functions of the process. For example, activity components carry application display-related content, while service components carry out tasks that are invisible to the user.

[0029] Memory recovery: When a process is newly created and its components haven't yet started, its memory usage is relatively small. As tasks within the process are triggered, components are started to handle them. As the process continues to run, the memory usage increases. Memory recovery restores the memory of a process to its initial state, streamlining its components and memory usage to increase system memory availability.

[0030] Process type: It can be classified according to the running status of the components in the process, for example, it can include but is not limited to: foreground process, visible process, service process and background process.

[0031] Foreground process: the process where the Activity component currently interacting with the user is located;

[0032] Visible process: does not include the Activity components being interacted with, but includes components visible to the user;

[0033] Service process: Contains the started Service component. The service process handles tasks or tasks in the background that the user cannot see, such as playing music and background downloading.

[0034] Background process: A process that handles background transactions that are not perceived by the user, such as updating the application version.

[0035] The memory management method, device, electronic device, and readable storage medium provided in the embodiments of the present application are described in detail below with reference to specific embodiments and their application scenarios in conjunction with the accompanying drawings.

[0036] The memory management method, device, electronic device, and readable storage medium provided in the embodiments of the present application can be applied to scenarios where process memory is reclaimed.

[0037] In the memory management method provided in the embodiments of the present application, a component's recycling priority can be determined based on the component's attribute-related information; and based on the component's recycling priority, whether to execute memory recycling processing on the component can be determined. In this way, since the component's memory can be recycled based on the attribute-related information of the component in the process, the electronic device's system memory, such as the operating memory, can be quickly restored, thereby improving and optimizing the electronic device's operating performance.

[0038] Furthermore, since memory recovery is performed in component units, the degree of process memory recovery can be improved while preventing the process from being killed.

[0039] Furthermore, since the memory occupied by the components can be reclaimed according to the recycling priority of the components, different memory recycling processes can be performed on components of different priorities, thereby improving the flexibility and diversity of memory recycling.

[0040] Furthermore, before executing memory recycling for components based on their recycling priorities, a component snapshot can be backed up in memory. This snapshot information indicates the component's content, allowing the component to be reloaded based on the snapshot information when sufficient memory is available. This can speed up component reloading and reduce the time it takes to reload components. This can also improve process startup speed.

[0041] It should be noted that since the memory occupied by the process is reclaimed by component, partial reclaim of the memory occupied by the process can be achieved, thereby keeping the process alive. That is, after executing memory reclaim processing on each component according to the recycling priority corresponding to each component in the process, the process remains alive, that is, it is not killed.

[0042] It can be seen that the memory management method provided in the embodiment of the present application can reduce the memory recovery time, improve the recovery efficiency, and avoid conflicts between process survival, application startup experience and memory recovery while ensuring that the process is not killed.

[0043] The execution subject of the memory management method provided in the embodiment of the present invention can be an electronic device, including a mobile electronic device or a non-mobile electronic device, or a functional module or functional entity in the electronic device that can implement the memory management method. The specific execution subject can be determined according to actual use requirements and is not limited by the embodiment of the present invention. The following takes the execution of the memory management method by an electronic device as an example to exemplify the memory management method provided in the embodiment of the present application.

[0044] FIG1 shows a possible method flow diagram of a memory management method provided in an embodiment of the present application. As shown in FIG1 , the memory management method provided in an embodiment of the present application may include step 101 and step 102 .

[0045] Step 101: The electronic device determines N recycling priorities corresponding to the N components based on attribute-related information of the N components.

[0046] Wherein, N is a positive integer.

[0047] Among them, the attribute-related information of the component can be used to reflect the survival importance of the component.

[0048] In the embodiment of the present application, the electronic device determines N recycling priorities corresponding to N components one by one based on the attribute-related information of the N components. This can be understood as: the electronic device determines the recycling priority corresponding to each component based on the attribute-related information of each component in the N components.

[0049] For example, the electronic device determines the recycling priority corresponding to component 1 based on the attribute-related information of component 1; the electronic device determines the recycling priority corresponding to component 2 based on the attribute-related information of component 2.

[0050] In some embodiments of the present application, the electronic device may first obtain attribute-related information of N components, and then determine N recycling priorities corresponding to the N components one-to-one based on the attribute-related information of the N components.

[0051] In the embodiment of the present application, the recycling priority corresponding to a component is negatively correlated with the importance of the component. That is, the higher the importance of a component, the lower its corresponding recycling priority, i.e., the possibility and degree of recycling of the memory occupied by the component are smaller.

[0052] In some embodiments of the present application, the attribute-related information of the component may indicate at least one of the following:

[0053] Whether the component is running;

[0054] Whether the component is running in the foreground;

[0055] The execution cycle of the component;

[0056] Whether the component contains scheduled tasks;

[0057] The duration of the component's completion task;

[0058] The component type of the component;

[0059] The process type of the process to which the component belongs.

[0060] In some embodiments of the present application, for a running component, the component can run in the foreground of the electronic device, that is, run in the foreground; or can run in the background of the electronic device, that is, run in the background.

[0061] In some embodiments of the present application, component types may include but are not limited to: active components, service components, content providing components, etc.

[0062] In some embodiments of the present application, process types may include, but are not limited to, foreground processes, service processes, visible processes, and background processes. For descriptions of foreground processes, service processes, visible processes, and background processes, see the relevant descriptions in the above glossary.

[0063] In some embodiments of the present application, the importance of a running component is greater than the importance of a non-running component.

[0064] In some embodiments of the present application, the importance of a component running in the foreground of the electronic device is greater than the importance of a component running in the background of the electronic device.

[0065] In some embodiments of the present application, the importance of a component including a scheduled task or a periodic task is greater than the importance of a component not including a scheduled task or a periodic task.

[0066] It is understandable that if other conditions of two components are not much different, the recycling priority can be sorted according to the time when the component tasks are completed.

[0067] In some embodiments of the present application, the longer it takes for a component to complete a task, the lower the importance of the component.

[0068] In some embodiments of the present application, the importance of the activity component, the service component, and the content providing component decreases in sequence.

[0069] In some embodiments of the present application, the importance of components in the foreground process, visible process, service process, and background process decreases in sequence.

[0070] The following further explains the principle of determining the recycling priority corresponding to a component based on the component's attribute-related information.

[0071] 1. For example, consider the component's execution cycle, which is information related to component attributes. For example, a resident process service may need to execute periodically, periodically running certain logic. Electronic devices can collect the regularity of these component's execution cycles and, based on these execution cycles, increase the priority of components that are not recycled, thereby lowering their corresponding recycling priority.

[0072] 2. Take the process type of the process to which the component belongs as an example, for example, if it is the main process of the application, which includes the user interface (UI) display function, then the service component in the main process may affect the UI display. Therefore, the priority of the service in the main process that will not be recycled can be increased, that is, the recycling priority corresponding to these components can be lowered.

[0073] 3. Taking the component type as an example, the component's attribute-related information is as follows: for example, an activity involves display, has high timeliness requirements, and is avoided as much as possible; a service is a background task, and its recycling priority can be lower than that of an activity; and a content provider can be the lowest of the three.

[0074] 4. Taking the attribute-related information of the component as an example, the duration of the component task completion, for example, when other conditions of the two components are not much different, the priority can be sorted according to the time when the component task is completed.

[0075] 5. Take the attribute-related information of a component, such as whether the component contains a scheduled task, as an example. For example, if the component contains a scheduled task, try not to recycle it before the scheduled task is completed. That is, the recycling priority of the component containing the scheduled task needs to be increased.

[0076] In some embodiments of the present application, assuming that recycling priorities are sorted from low to high, the following order applies: services with periodic execution requirements < components containing scheduled tasks < activities < services in the process of displaying activities < ordinary services. In other words, services other than services with periodic execution requirements and services in the process of displaying activities < content providers. Ordinary services and content providers can be sorted based on the time it takes for tasks to complete.

[0077] In some embodiments of the present application, in combination with FIG. 1 , as shown in FIG. 2 , in some embodiments of the present application, the above step 101 can be specifically implemented through the following step 101a.

[0078] Step 101a: When the memory recycling triggering condition is met, the electronic device determines N recycling priorities corresponding to the N components according to the attribute-related information of the N components.

[0079] The memory recycling triggering condition may include at least one of the following:

[0080] The component ends the task;

[0081] The memory occupied by the process is greater than or equal to the memory threshold;

[0082] The system memory status has changed.

[0083] In the embodiment of the present application, the component completing the task may also be referred to as component timeout.

[0084] In some embodiments of the present application, different processes may correspond to different memory thresholds, or different processes may correspond to the same memory threshold, which may be determined based on actual usage requirements.

[0085] In some embodiments of the present application, the electronic device may configure a memory threshold for each process based on the application type of the process or the process type of the process. If the memory occupied by the process is greater than or equal to the memory threshold corresponding to the process, it means that the memory recycling trigger condition is met.

[0086] For example, the electronic device can set a memory threshold a for the foreground process, a memory threshold b for the visible process, a memory threshold c for the service process, and a memory threshold d for the background process. Memory thresholds a, b, c, and d decrease in order.

[0087] In some embodiments of the present application, the system memory status may include: system memory occupancy status or system memory remaining status. The system memory occupancy status may be represented by the amount of system memory occupied or the proportion of system memory occupied. The system memory remaining status may be represented by the remaining amount of system memory or the proportion of remaining system memory.

[0088] In some embodiments of the present application, a change in the system memory state may include: a change in the amount of system memory occupied, or a change in the remaining amount of system memory.

[0089] In some embodiments of the present application, regardless of the memory recycling triggering conditions met, the electronic device can determine the recycling priorities corresponding to the components of all processes in the system memory; in other words, the above N components include all components in the system memory.

[0090] It should be noted that the "system memory" in the embodiments of the present application can be understood as "running memory" or "system running memory".

[0091] In some embodiments of the present application, the memory recycling triggering conditions satisfied by the electronic device are different, and the above-mentioned N components may also be different.

[0092] (i) In the case where a component ends a task, the N components include at least one of the following: a component that ends the task, and a component associated with the component that ends the task.

[0093] It should be noted that, when two components are associated, the two components satisfy at least one of the following conditions: there is information interaction between the two components, and there is information interaction between the two components and the same component.

[0094] For example, if the processing result data of component 1 is the input data of component 2, then component 1 and component 2 are associated.

[0095] For example, if the input data of component 1 is the processing result data of component 2, and the input data of component 3 is also the processing result data of component 2, then component 1 and component 3 are associated.

[0096] In this way, since the electronic device can determine the recycling priority corresponding to the component and at least one of the components associated with the component after the component completes the task execution, the electronic device can promptly recycle the memory occupied by the component that completes the task and at least one of the components associated with the component that completes the task, thereby improving the operating performance of the electronic device.

[0097] (2) When the memory occupied by the process is greater than or equal to the memory threshold, the N components include at least one of the following: a component of the process, and a component of a process associated with the process.

[0098] It should be noted that, if two processes are associated, then the two processes satisfy at least one of the following conditions: there is information interaction between the two processes, and there is information interaction between the two processes and the same component or the same process.

[0099] For example, if the processing result data of process 1 is the input data of process 2, then process 1 and process 2 are associated.

[0100] For example, if the input data of process 1 is the processing result data of process 2, and the input data of process 3 is also the processing result data of process 2, then process 1 and process 3 are associated.

[0101] For example, if the input data of process 1 includes the processing result data of component 0, and the input data of process 3 also includes the processing result data of component 0, then process 1 and process 3 are associated.

[0102] In an embodiment of the present application, the electronic device can scan all components of a process when it determines that the memory occupied by a process is greater than or equal to the memory threshold corresponding to the process to obtain attribute-related information of all components of the process, and then determine the recycling priority corresponding to each component based on the attribute-related information of each component.

[0103] For example, if the electronic device determines that the memory occupied by foreground process a is greater than its corresponding memory threshold, and foreground process a includes 20 components, the electronic device can obtain attribute-related information of the 20 components, and then determine 20 recycling priorities corresponding to the 20 components based on the attribute-related information of the 20 components. In this way, the electronic device can determine which of the 20 components' occupied memory can be recycled based on the 20 recycling priorities, and the degree to which the recycled components can be recycled.

[0104] In this way, when the memory occupied by a process is greater than or equal to the memory threshold, the electronic device can determine the recycling priority corresponding to each component of the process based on the attribute-related information of each component of the process, and / or determine the recycling priority corresponding to each component of the process associated with the process based on the attribute-related information of each component of the process. This facilitates the electronic device to recover the memory occupied by one or more processes on a component-by-component basis. This can improve the flexibility of recovering process memory usage.

[0105] (3) When the system memory state changes, the N components may include: components of all processes in the system memory.

[0106] In an embodiment of the present application, when the system memory state changes, the electronic device can scan the components in all processes in the system memory on a process basis to obtain attribute-related information of the components in all processes, and determine the recycling priority corresponding to each component based on the attribute-related information of each component.

[0107] For example, suppose an electronic device's running memory includes two processes: foreground process a and background process b. Foreground process a includes components 1 and 2, while background process b includes components 2 and 4. When the system memory status changes, such as entering a low-memory state, the electronic device can determine the recycling priority for component 1 based on the properties of component 1; the recycling priority for component 2 based on the properties of component 2; the recycling priority for component 3 based on the properties of component 3; and the recycling priority for component 4 based on the properties of component 4. This yields four recycling priorities.

[0108] In this way, since the electronic device determines the recycling priorities corresponding to all components in the system memory when the system memory state changes, the system memory can be restored to the greatest extent at one time.

[0109] Step 102: The electronic device performs memory recycling processing on M components among the N components according to N recycling priorities.

[0110] Wherein, M is an integer greater than or equal to 0 and less than or equal to N.

[0111] In some embodiments of the present application, the M components may be at least some of the N components. For example, the M components may be the components with the lowest recycling priority among the N components.

[0112] In some embodiments of the present application, the recycling priorities corresponding to the M components are lower than the recycling priorities corresponding to the components other than the M components among the N components.

[0113] In some embodiments of the present application, the electronic device may keep the memory occupied by components other than M components among N components unchanged, or the electronic device may not perform memory recycling processing on components other than M components among N components.

[0114] In an embodiment of the present application, the purpose of the electronic device performing memory recycling processing on M of N components according to N recycling priorities is to reduce the memory usage of the process in which the component is located, such as restoring the memory occupied when the process was just created, thereby increasing the remaining memory of the system memory.

[0115] In the embodiment of the present application, since memory is recovered according to components, the process containing the component can be prevented from being killed. That is, the survival of the process can be guaranteed while the memory usage of the process is restored.

[0116] In the embodiment of the present application, the electronic device can perform memory recycling processing on each component according to the recycling priority corresponding to each component in the M components.

[0117] Specifically, the electronic device may determine a memory recycling policy corresponding to each component according to the recycling priority corresponding to each component, and reclaim the memory occupied by each component according to the memory recycling policy.

[0118] For example, the electronic device performs memory recycling on component 1 based on the recycling priority of component 1, and performs memory recycling on component 2 based on the recycling priority of component 2. The memory recycling processes performed on components 1 and 2 are determined based on their respective recycling priorities.

[0119] In some embodiments of the present application, the electronic device may perform different memory recycling processes on components corresponding to different recycling priorities, which may be determined based on actual usage requirements, such as the system memory status.

[0120] In some embodiments of the present application, the "memory recycling process" in step 102 includes at least one of the following:

[0121] (4) The electronic device destroys components from the system memory;

[0122] (5) Part of the memory occupied by recycled components of electronic equipment.

[0123] It should be noted that for each of the M components above, the electronic device can destroy the component from the system memory, or can reclaim part of the memory occupied by the component. It is understood that the electronic device performs the processing shown in (4) or (5) above on each of the M components above. The memory recycling processing of different components in the M components can be the same or different, and can be determined based on actual usage requirements.

[0124] In (IV), destroying the component from the system memory can also be referred to as: deleting all algorithms of the component from the system memory, or removing all algorithms of the component from the system memory. After destroying the component from the system memory, the system memory does not include the component, and thus the component is inactivated.

[0125] In some embodiments of the present application, destroying a component from the system memory can be understood as destroying the component from the running memory of the electronic device. Destroying a component means releasing all contents in the component to reclaim all memory occupied by the component.

[0126] In (5), the electronic device reclaiming part of the memory occupied by the component can be understood as: the electronic device destroying part of the content in the component, such as some logical algorithms, to reclaim the memory occupied by such content. For example, the electronic device destroys unimportant logical algorithms in the component, such as some logical algorithms used only for performance optimization.

[0127] In (V), the recycling priorities corresponding to the components are different, and the degree or proportion of recycling of the memory occupied by the components by the electronic device may be different.

[0128] For example, suppose there are two components among M components: Component 1, Component 2, and Component 3. Component 1 is a service with periodic execution requirements, Component 2 is a component with scheduled tasks, and Component 3 is a normal service. Components 1 through 3 are arranged in descending order of recycling priority: Component 1, Component 2, Component 3. Then, the electronic device can reclaim 10% of the memory used by Component 1, 20% of the memory used by Component 2, and 70% of the memory used by the components.

[0129] It should be noted that (5) reclaims part of the memory occupied by the component, that is, the other part of the memory is not reclaimed, so that the component still survives.

[0130] In some embodiments of the present application, in step (5), the electronic device can reclaim the Java heap in the component through the garbage collector (GC), such as by adopting the Android native recycling strategy to reclaim the freed memory in the component through the garbage collector. Alternatively, the electronic device can use trim memory to reclaim unimportant parts of the component; for example, the application developer can use the Android native recycling strategy to rewrite the component's trim memory (onTrimMemory) to define which content of the component can be recycled.

[0131] In this way, because the memory recycling process that the electronic device can perform on the components is related to the recycling priority corresponding to the components, such as determined by the recycling priority of the components, the electronic device can perform different levels or degrees of recycling on different components of the process according to the recycling priority corresponding to the components within the process. For example, the memory occupied by important components is maintained as much as possible, while the memory occupied by unimportant components is recycled. This can restore as much memory usage as possible for the process while ensuring that the process is not destroyed. This can not only improve memory recycling efficiency but also ensure that the process is kept alive.

[0132] In some embodiments of the present application, when M is greater than 1, the electronic device may perform corresponding memory recycling processing on the M components in descending order of recycling priority, according to the recycling priority corresponding to each of the M components. For example, the electronic device may first recycle the memory occupied by components corresponding to higher recycling priorities, and then recycle the memory occupied by components corresponding to lower recycling priorities; or first recycle the memory occupied by unimportant components, and then recycle the memory occupied by important components.

[0133] In some embodiments of the present application, components have different recycling priorities, and the electronic device may perform different memory recycling processes on the components based on the recycling priorities corresponding to the components.

[0134] For example, assuming that the recycling priorities of component 1, component 2, and component 3 decrease in sequence, the electronic device can destroy component 1 from the system memory, destroy unimportant logic in component 2, and keep the memory occupied by component 3 unchanged, that is, do not destroy any logic in component 3.

[0135] In this way, for each of the M components requiring memory recycling, the electronic device can destroy a component from the system memory or reclaim part of the memory occupied by the component, thereby improving the flexibility of performing memory recycling processing on the component.

[0136] In some embodiments of the present application, the above step 102 can be specifically implemented through the following steps 102a and 102b.

[0137] Step 102a: The electronic device determines M components from N components according to N recycling priorities.

[0138] In some embodiments, the electronic device may sort N components in descending order of N recycling priorities and select the first M components from the N components. Alternatively, the electronic device may divide the N components into multiple groups according to recycling priorities, sort the multiple groups in descending order of priority, and select components in at least one of the multiple groups as the M components.

[0139] Step 102b: The electronic device performs memory recycling processing on the M components according to the recycling priorities of the M components.

[0140] In some embodiments of the present application, different reclamation priorities correspond to different memory reclamation processes, or different memory reclamation priority ranges correspond to different memory reclamation processes.

[0141] Exemplarily, for each of the M components, if the recycling priority corresponding to a component is greater than or equal to a first recycling priority threshold, the electronic device may destroy the component from the system memory.

[0142] If the recycling priority corresponding to a component is less than the first recycling priority threshold, the electronic device can recycle part of the memory occupied by the component. Furthermore, if the recycling priority corresponding to the component is greater than or equal to the second recycling priority threshold, the electronic device can recycle 90% of the memory occupied by the component; if the recycling priority corresponding to the component is less than the second recycling priority threshold and greater than or equal to the third recycling priority threshold, the electronic device can recycle 70% of the memory occupied by the component; if the recycling priority corresponding to the component is less than the third recycling priority threshold and greater than or equal to the third recycling priority threshold, the electronic device can recycle 60% of the memory occupied by the component.

[0143] The first recycling priority threshold is greater than the second recycling priority threshold and greater than the third recycling priority threshold.

[0144] It should be noted that the number of the above recycling priority thresholds is only for illustration, and in actual implementation, more or fewer recycling priority thresholds may be used to recycle the memory occupied by components.

[0145] For example, assume that recycling priority range 1 corresponds to destroying components from memory, and recycling priority range 2 corresponds to recycling part of the memory occupied by the components.

[0146] Furthermore, recycling priority range 2 includes multiple recycling priority sub-ranges, and each recycling priority sub-range corresponds to a recycling ratio.

[0147] It should be noted that FIG3 is an illustration of an example in which step 102a and step 102b are performed after step 101. In actual implementation, step 102a and step 102b may be performed after step 101a.

[0148] In this way, since the electronic device can determine M components from N components according to the recycling priorities corresponding to the N components, and then recycle the memory occupied by these M components according to the recycling priorities corresponding to each component in the M components, the accuracy of memory recovery can be improved.

[0149] In some embodiments of the present application, in combination with FIG. 1 , as shown in FIG. 4 , the above step 102 may be specifically implemented through the following step 102 c.

[0150] Step 102c: The electronic device performs memory recycling processing on M components among the N components according to the system memory status and the N recycling priorities.

[0151] It should be noted that the M components are determined by the electronic device from the N components based on the system memory state and the at least one recycling priority. Furthermore, the memory recycling process performed by the electronic device on the M components is also related to the system memory state and the recycling priority of the components.

[0152] In some embodiments of the present application, the less the remaining system memory indicated by the system memory status, the more M components the electronic device determines from N components; and the higher the degree or proportion of recovery of the memory occupied by the M components by the electronic device.

[0153] For example, assuming that the N components are 10 components, and the recycling priorities of the 10 components decrease in sequence, then:

[0154] (1) If the system memory status indicates that the remaining amount of system memory is greater than a first low memory threshold, such as 50%, it means that the remaining system memory is sufficient, so that the electronic device can perform partial recycling processing on the components with the highest priority, such as destroying unimportant logic in these components and keeping the memory occupied by components with other recycling priorities unchanged.

[0155] (2) If the system memory status indicates that the remaining amount of the system memory is less than or equal to the first low memory threshold and greater than the second low memory threshold, such as 30%, it indicates that the remaining amount of the system memory may be insufficient, so that the electronic device can destroy the component with the highest priority from the 10 components in the system memory, keep the memory occupied by the component with the lowest recycling priority unchanged, and destroy unimportant logic in the other components.

[0156] (3) If the system memory status indicates that the remaining amount of the system memory is less than or equal to the second lowest memory threshold and greater than the third lowest memory threshold, such as 20%, it means that the remaining amount of the system memory is insufficient, so that the electronic device can destroy the 10 components from the system memory to recycle the components with the highest and second highest priority, while keeping the memory occupied by the component with the lowest recycling priority unchanged, and destroying unimportant logic in other components.

[0157] (4) If the system memory indicates that the remaining amount of system memory is less than or equal to the third lower memory threshold and greater than the fourth lower memory threshold, such as 5%, it indicates that the remaining amount of system memory is seriously insufficient, so that the electronic device can destroy the other components of the 10 components except the component with the lowest priority from the system memory and destroy unimportant logic in the component with the lowest priority.

[0158] (5) If the remaining amount of system memory indicated by the system memory is less than or equal to the fourth lowest memory threshold, it indicates that the electronic device has been frozen, and therefore the electronic device may destroy 10 components from the system memory. In other words, all memory occupied by all components is fully recycled.

[0159] It can be seen that the first low memory threshold, the second low memory threshold, the third low memory threshold, and the fourth low memory threshold decrease in sequence.

[0160] The number of low memory thresholds in the above example is for illustration only. In actual implementation, more or fewer low memory thresholds may be used to reclaim the memory occupied by components.

[0161] For other descriptions of step 102c, please refer to the relevant descriptions of step 102a and step 102b in the above embodiment, which will not be repeated here to avoid repetition.

[0162] In this way, memory reclamation can be performed on M of N components based on the system memory status and N reclamation priorities. This means that the electronic device can determine whether to reclaim the memory occupied by the components in the process, and the extent of the reclamation, based on the level of system memory shortage. This ensures that the remaining system memory is sufficient for normal use by subsequent programs, while also ensuring the survival of the process to the greatest extent possible. This resolves the conflict between process survival, application startup experience, and memory reclamation.

[0163] In the above embodiment, step 102c is performed after step 101 as an example. In actual implementation, step 102c may also be performed after step 101a.

[0164] In this way, since N recycling priorities corresponding to the N components can be determined one by one based on the attribute-related information of the N components, and memory recycling processing can be directly performed on M components among the N components based on the recycling priorities corresponding to the N components, the time consumed in memory recycling can be reduced and the memory recycling efficiency can be improved.

[0165] In some embodiments of the present application, in combination with the above-mentioned Figure 1, as shown in Figure 5, before the above-mentioned step 102, the memory management method provided by the embodiment of the present application may further include the following step 103, and after the above-mentioned step 102, the memory management method provided by the embodiment of the present application may further include the following step 104.

[0166] Step 103: The electronic device backs up snapshot information of M components.

[0167] The snapshot information of the component indicates the content of the component.

[0168] It can be understood that the snapshot information of the M components backed up by the electronic device can indicate the contents of the M components before the electronic device performs memory recycling processing on the M components.

[0169] In some embodiments of the present application, the electronic device may back up snapshot information of M components in the system memory.

[0170] In some embodiments of the present application, the snapshot information of a component may include but is not limited to at least one of the following: snapshot information of a component page, snapshot information of a component logic algorithm, and the like.

[0171] It is understandable that the snapshot information of a component occupies a small amount of memory, at the KB level.

[0172] In some embodiments of the present application, the electronic device may associate and back up snapshot information of M components with information of processes to which the M components belong, such as an identifier of the process.

[0173] Specifically, the electronic device may generate a mapping table between the snapshot information of the M components and the information of the processes to which the M components belong.

[0174] It can be understood that after the electronic device determines M components from N components, it can first obtain snapshot information of the M components and then back up the snapshot information of the M components.

[0175] It can be understood that the snapshot information of a component can also be called the activity record of the component.

[0176] Step 104: The electronic device reloads the M components according to the snapshot information of the M components.

[0177] In some embodiments of the present application, when the system memory of the electronic device is sufficient, the M components can be reloaded into the memory according to the snapshot information of the M components that have been backed up.

[0178] In some embodiments of the present application, the electronic device may back up snapshot information of a component that may be recycled during the process, so as to restore the content of the component when there is sufficient memory.

[0179] For example, retaining an activity's activity record, which is just a snapshot of the component and has minimal impact on memory usage, is performed in KBs. When sufficient memory is available, system interfaces, such as the startActivity interface, can be used to reload the activity into the process based on the retained snapshot information, reducing component reload time.

[0180] In some embodiments of the present application, the electronic device may further back up recycling priorities corresponding to M components.

[0181] It should be noted that the electronic device can load M components in multiple times, or load M components at one time.

[0182] For example, the electronic device may reload the M components according to the recycling priorities corresponding to the M components, in sequence according to the recycling priorities corresponding to the components.

[0183] For the description of step 101 and step 102, refer to the relevant description in the above embodiment.

[0184] In this way, since the snapshot information of M components can be backed up, the electronic device can reload the corresponding components according to the backed-up snapshot information when the memory is sufficient, thereby reducing the time consumed in reloading the components and improving the operating performance of the electronic device.

[0185] The memory management method provided in the embodiment of the present application can be executed by a memory management device. In the embodiment of the present application, the memory management device provided in the embodiment of the present application is described by taking the memory management device executing the memory management method as an example.

[0186] An embodiment of the present application provides a memory management device. FIG6 shows a schematic structural diagram of a memory management device provided by the embodiment of the application. As shown in FIG6 , the memory management device 500 may include: a determination module 501 and a processing module 502 .

[0187] A determination module 501 is configured to determine N recycling priorities corresponding to the N components based on attribute-related information of the N components;

[0188] The processing module 502 is configured to perform memory recycling processing on M components among the N components according to the N recycling priorities determined by the determining module 501 , where N and M are positive integers and M is less than or equal to N.

[0189] In some embodiments of the present application, the attribute-related information of the component indicates at least one of the following:

[0190] Whether the component is running;

[0191] Whether the component is running in the foreground;

[0192] The execution cycle of the component;

[0193] Whether the component contains scheduled tasks;

[0194] The duration of the component's completion task;

[0195] The component type of the component;

[0196] The process type of the process to which the component belongs.

[0197] In some embodiments of the present application, the processing module 502 is specifically configured to perform memory recycling processing on M components out of N components according to a system memory state and N recycling priorities.

[0198] In some embodiments of the present application, the memory reclaiming process may include at least one of the following:

[0199] Destroy the component from system memory;

[0200] Reclaim some of the memory occupied by the component.

[0201] In some embodiments of the present application, the determination module 501 is specifically configured to determine N recycling priorities corresponding to the N components based on attribute-related information of the N components when a memory recycling trigger condition is met;

[0202] The memory recycling triggering conditions include at least one of the following:

[0203] The component ends the task;

[0204] The memory occupied by the process is greater than or equal to the memory threshold;

[0205] The system memory status has changed.

[0206] In some embodiments of the present application, in the case where a component ends a task, the N components include at least one of the following: a component that ends the task, a component associated with the component that ends the task; or,

[0207] In the case where the memory occupied by the process is greater than or equal to the memory threshold, the N components include at least one of the following: a component of the process, a component of a process associated with the process; or,

[0208] In the case where the system memory state changes, the N components include: components of all processes in the system memory.

[0209] In some embodiments of the present application, the processing module 502 is specifically configured to determine M components from N components according to N recycling priorities; and perform memory recycling processing on the M components respectively according to the recycling priorities of the M components.

[0210] In some embodiments of the present application, the processing module 502 is specifically configured to back up snapshot information of the M components before performing memory reclamation processing on M components among the N components according to N reclamation priorities, where the snapshot information of the components is used to indicate the content of the components;

[0211] The processing module 502 is further configured to, after executing memory recycling processing on M components among the N components according to the N recycling priorities, reload the M components according to snapshot information of the M components.

[0212] In this way, since N recycling priorities corresponding to the N components can be determined one by one based on the attribute-related information of the N components, and memory recycling processing can be directly performed on M components of the N components based on the recycling priorities corresponding to the N components, the system memory of the electronic device, such as the running memory, can be quickly restored, thereby improving and optimizing the running performance of the electronic device.

[0213] The memory management device in the embodiment of the present application can be an electronic device or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices other than a terminal. For example, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a mobile Internet device (MID), an augmented reality (AR) / virtual reality (VR) device, a robot, a wearable device, an ultra-mobile personal computer (UMPC), a netbook or a personal digital assistant (PDA), etc. It can also be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine or a self-service machine, etc., and the embodiment of the present application does not specifically limit it.

[0214] The memory recovery in the embodiment of the present application can be a device having an operating system. The operating system can be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.

[0215] The memory recovery provided in the embodiment of the present application can implement each process implemented by the method embodiment shown in Figures 1 to 5. To avoid repetition, they will not be described here.

[0216] Optionally, as shown in Figure 7, an embodiment of the present application also provides an electronic device 600, including a processor 601 and a memory 602, and the memory 602 stores a program or instruction that can be run on the processor 601. When the program or instruction is executed by the processor 601, the various steps of the above-mentioned memory management method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0217] FIG8 is a schematic diagram of the hardware structure of an electronic device implementing an embodiment of the present application.

[0218] The electronic device 700 includes but is not limited to components such as a radio frequency unit 701 , a network module 702 , an audio output unit 703 , an input unit 704 , a sensor 705 , a display unit 706 , a user input unit 707 , an interface unit 708 , a memory 709 , and a processor 710 .

[0219] Those skilled in the art will appreciate that the electronic device 700 may further include a power source (e.g., a battery) to power various components. The power source may be logically connected to the processor 710 via a power management system, thereby enabling the power management system to manage charging, discharging, and power consumption. The electronic device structure shown in FIG8 does not limit the electronic device. The electronic device may include more or fewer components than shown, or may combine certain components or arrange the components differently, which will not be described in detail here.

[0220] The processor 710 is configured to determine N recycling priorities corresponding to the N components based on the attribute-related information of the N components;

[0221] The processor 710 is configured to perform memory recycling processing on M components among the N components according to N recycling priorities determined by the processor 710 , where N and M are positive integers and M is less than or equal to N.

[0222] In some embodiments of the present application, the attribute-related information of the component indicates at least one of the following:

[0223] Whether the component is running;

[0224] Whether the component is running in the foreground;

[0225] The execution cycle of the component;

[0226] Whether the component contains scheduled tasks;

[0227] The duration of the component's completion task;

[0228] The component type of the component;

[0229] The process type of the process to which the component belongs.

[0230] In some embodiments of the present application, the processor 710 is specifically configured to perform memory reclamation processing on M components out of N components according to a system memory state and N reclamation priorities.

[0231] In some embodiments of the present application, the memory reclaiming process may include at least one of the following:

[0232] Destroy the component from system memory;

[0233] Reclaim some of the memory occupied by the component.

[0234] In some embodiments of the present application, the processor 710 is specifically configured to determine N recycling priorities corresponding to the N components one by one based on attribute-related information of the N components when a memory recycling trigger condition is met;

[0235] The memory recycling triggering conditions include at least one of the following:

[0236] The component ends the task;

[0237] The memory occupied by the process is greater than or equal to the memory threshold;

[0238] The system memory status has changed.

[0239] In some embodiments of the present application, in the case where a component ends a task, the N components include at least one of the following: a component that ends the task, a component associated with the component that ends the task; or,

[0240] In the case where the memory occupied by the process is greater than or equal to the memory threshold, the N components include at least one of the following: a component of the process, a component of a process associated with the process; or,

[0241] In the case where the system memory state changes, the N components include: components of all processes in the system memory.

[0242] In some embodiments of the present application, the processor 710 is specifically configured to determine M components from N components according to N recycling priorities; and perform memory recycling processing on the M components respectively according to the recycling priorities of the M components.

[0243] In some embodiments of the present application, the processor 710 is specifically configured to back up snapshot information of the M components before performing memory reclamation processing on M components among N components according to N reclamation priorities, where the snapshot information of the components is used to indicate content of the components;

[0244] The processor 710 is further configured to, after executing memory recycling processing on M components among the N components according to the N recycling priorities, reload the M components according to snapshot information of the M components.

[0245] In this way, since N recycling priorities corresponding to the N components can be determined one by one based on the attribute-related information of the N components, and memory recycling processing can be directly performed on M components of the N components based on the recycling priorities corresponding to the N components, the system memory of the electronic device, such as the running memory, can be quickly restored, thereby improving and optimizing the running performance of the electronic device.

[0246] It should be understood that in an embodiment of the present application, the input unit 704 may include a graphics processing unit (GPU) 7041 and a microphone 7042, and the graphics processor 7041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The display unit 706 may include a display panel 7061, and the display panel 7061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 707 includes a touch panel 7071 and at least one of other input devices 7072. The touch panel 7071 is also called a touch screen. The touch panel 7071 may include two parts: a touch detection device and a touch controller. Other input devices 7072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and an operating stick, which will not be repeated here.

[0247] The memory 709 can be used to store software programs and various data. The memory 709 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, applications or instructions required for at least one function (such as a sound playback function, an image playback function, etc.). In addition, the memory 709 may include a volatile memory or a non-volatile memory, or the memory 709 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM), and a direct memory bus random access memory (DRRAM). The memory 709 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.

[0248] Processor 710 may include one or more processing units. Optionally, processor 710 integrates an application processor and a modem processor. The application processor primarily handles operations related to the operating system, user interface, and application programs, while the modem processor primarily processes wireless communication signals, such as a baseband processor. It is understood that the modem processor may not be integrated into processor 710.

[0249] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned memory management method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0250] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0251] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned memory management method embodiment and achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0252] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0253] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned memory management method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0254] It should be noted that, in this article, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element. In addition, it should be noted that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in the opposite order according to the functions involved. For example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0255] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), including a number of instructions for enabling a terminal (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0256] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of this application, ordinary technicians in this field can also make many forms without departing from the purpose of this application and the scope of protection of the claims, all of which are within the protection of this application.

Claims

1. A memory management method, the method include: Determine, according to the attribute-related information of the N components, N recycling priorities corresponding to the N components one by one; According to the N recycling priorities, memory recycling processing is performed on M components of the N components, where N and M are positive integers and M is less than or equal to N.

2. The method according to claim 1, in, The component's property-related information indicates at least one of the following: Whether the component is running; Whether the component is running in the foreground; The execution cycle of the component; Whether the component contains scheduled tasks; The duration of the component to complete the task; The component type of the component; The process type of the process to which the component belongs.

3. The method according to claim 1, in, The performing memory recycling processing on M components of the N components according to the N recycling priorities includes: Memory recycling processing is performed on M components of the N components according to the system memory state and the N recycling priorities.

4. The method according to any one of claims 1 to 3, in, The memory recycling process includes at least one of the following: Destroys the component from system memory; Reclaim some of the memory used by the component.

5. The method according to claim 1, in, The determining, according to the attribute-related information of the N components, N recycling priorities corresponding to the N components one by one, includes: When the memory recycling triggering condition is met, determining N recycling priorities corresponding to the N components one by one according to the attribute related information of the N components; The memory recycling triggering condition includes at least one of the following: Component ends task; The memory occupied by the process is greater than or equal to the memory threshold; The system memory status has changed.

6. The method according to claim 5, in, In the case where a component ends a task, the N components include at least one of the following: a component that ends the task, a component associated with the component that ends the task; or, In the case where the memory occupied by the process is greater than or equal to the memory threshold, the N components include at least one of the following: a component of the process, a component of a process associated with the process; or, When the system memory state changes, the N components include: components of all processes in the system memory.

7. The method according to claim 1, in, The performing memory recycling processing on M components of the N components according to the N recycling priorities includes: Determining M components from the N components according to the N recycling priorities; Memory recycling processing is performed on the M components respectively according to the recycling priorities of the M components.

8. The method according to claim 1, in, Before performing memory recycling processing on M components of the N components according to the N recycling priorities, the method further includes: Backing up snapshot information of the M components, where the snapshot information of the components is used to indicate content of the components; After performing memory recycling processing on M components of the N components according to the N recycling priorities, the method further includes: Reload the M components according to the snapshot information of the M components.

9. A memory management device, the device include: Determine modules and process modules; The determination module is used to determine N recycling priorities corresponding to the N components one by one according to the attribute-related information of the N components; The processing module is used to process the N recycling priorities determined by the determining module. M components among the N components perform memory recycling processing, N and M are positive integers, and M is less than or equal to N.

10. The device according to claim 9, in, The component's property-related information indicates at least one of the following: Whether the component is running; Whether the component is running in the foreground; The execution cycle of the component; Whether the component contains scheduled tasks; The duration of the component to complete the task; The component type of the component; The process type of the process to which the component belongs.

11. The device according to claim 9, in, The processing module is specifically configured to perform memory recycling processing on M components among the N components according to the system memory status and the N recycling priorities.

12. The device according to any one of claims 9 to 11, in, The memory recycling process includes at least one of the following: Destroys the component from system memory; Reclaim some of the memory used by the component.

13. The device according to claim 9, in, The determination module is specifically configured to determine N recycling priorities corresponding to the N components one by one according to the attribute-related information of the N components when the memory recycling triggering condition is met; The memory recycling triggering condition includes at least one of the following: Component ends task; The memory occupied by the process is greater than or equal to the memory threshold; The system memory status has changed.

14. The device according to claim 13, in, In the case where a component ends a task, the N components include at least one of the following: a component that ends the task, a component associated with the component that ends the task; or, In the case where the memory occupied by the process is greater than or equal to the memory threshold, the N components include at least one of the following: a component of the process, a component of a process associated with the process; or, When the system memory state changes, the N components include: components of all processes in the system memory.

15. The device according to claim 9, in, The processing module is specifically used to determine M components from the N components according to the N recycling priorities; and to perform memory recycling processing on the M components respectively according to the recycling priorities of the M components.

16. The device according to claim 9, in, The processing module is specifically configured to back up snapshot information of the M components before executing memory recycling processing on M components of the N components according to the N recycling priorities, where the snapshot information of the components is used to indicate the content of the components; The processing module is further configured to, after performing memory recycling processing on M components among the N components according to the N recycling priorities, reload the M components according to snapshot information of the M components.

17. An electronic device comprising a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the memory management method according to any one of claims 1 to 8 are implemented.

18. A readable storage medium storing a program or an instruction, wherein the program or the instruction, when executed by a processor, implements the steps of the memory management method according to any one of claims 1 to 8.

19. An electronic device configured to implement the memory management method according to any one of claims 1-8.

20. A chip comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the memory management method according to any one of claims 1 to 8.

21. A computer program product, wherein when instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the memory management method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Method and device for achieving process recycling in application

    CN105573842A

  • Memory management method and device, equipment and storage medium

    CN112463374A

  • Component memory management and control method and device and computer readable storage medium

    CN114064287A

  • Memory recovery method and device

    CN115509953A

  • Memory management method and device, electronic equipment and readable storage medium

    CN116483575A