Memory management method and apparatus, device, and storage medium

CN123011476APending Publication Date: 2026-10-30GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510553632.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-28
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0003]但是,上述内存管理方法不灵活

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123011476A_ABST
    Figure CN123011476A_ABST
Patent Text Reader

Abstract

The application provides a memory management method and device, equipment and a storage medium, realizes a high-flexibility memory management effect, and improves the efficiency of memory management. The method comprises the following steps: in the case that an electronic device is in a memory management scene, performing a memory management operation on the electronic device in descending order of priority, the memory management operation comprising at least two of a process cleaning operation, a garbage collection operation and a compression operation; wherein the priority of the process cleaning operation is higher than the priority of the garbage collection operation and the compression operation, and the priority of the garbage collection operation is higher than the priority of the compression operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a memory management method, apparatus, device, and storage medium. Background Technology

[0002] As electronic devices become increasingly feature-rich, the demands on RAM also rise. Currently, memory management techniques can optimize memory usage, improving the smoothness of electronic device operation and enhancing the user experience.

[0003] However, the above memory management methods are inflexible. Summary of the Invention

[0004] This application provides a memory management method, apparatus, device, and storage medium that achieves highly flexible memory management and improves memory management efficiency.

[0005] Firstly, a memory management method is provided for use in an electronic device. The memory management method includes: when the electronic device is in a memory management scenario, performing memory management operations on the electronic device in descending order of priority. The memory management operations include at least two of the following: process cleanup operation, garbage collection operation, and compression operation; wherein the priority of the process cleanup operation is higher than the priority of the garbage collection operation and the compression operation, and the priority of the garbage collection operation is higher than the priority of the compression operation.

[0006] In this application, an electronic device can perform memory management operations when in a memory management scenario. These memory management operations can include at least two of the following: process cleanup, garbage collection, and compaction. This allows the electronic device to release as much memory as possible by performing these memory management operations. The process cleanup operation has a higher priority than the garbage collection and compaction operations, and the garbage collection operation has a higher priority than the compaction operation. When performing these memory management operations, the electronic device can execute at least two of the above-mentioned memory management operations in descending order of priority. This avoids the additional overhead of performing garbage collection and / or compaction operations on the running process of the executable process cleanup operation, and / or performing compaction operations on the running process of the executable garbage collection operation. This achieves highly flexible memory management, improves memory management efficiency, and reduces memory management overhead.

[0007] Secondly, a memory management device is provided for use in an electronic device. The memory management device includes a memory management module, which is used to perform memory management operations on the electronic device in a memory management scenario, in descending order of priority. The memory management operations include at least two of the following: process cleanup operation, garbage collection operation, and compression operation; wherein the priority of the process cleanup operation is higher than the priority of the garbage collection operation and the compression operation, and the priority of the garbage collection operation is higher than the priority of the compression operation.

[0008] Thirdly, an electronic device is provided, including a processor coupled to a memory for executing instructions in the memory to implement the method in any of the possible implementations of the first aspect described above. Optionally, the electronic device further includes a memory. Optionally, the electronic device further includes a communication interface, to which the processor is coupled.

[0009] Fourthly, a processor is provided, comprising: an input circuit, an output circuit, and a processing circuit. The processing circuit is used to receive signals through the input circuit and transmit signals through the output circuit, causing the processor to execute the method in any possible implementation of the first aspect described above.

[0010] In specific implementation, the processor can be a chip, the input circuit can be an input pin, the output circuit can be an output pin, and the processing circuit can be a transistor, gate circuit, flip-flop, and various logic circuits. The input signal received by the input circuit can be received and input by, for example, but not limited to, a receiver, and the signal output by the output circuit can be output to, for example, but not limited to, a transmitter and transmitted by the transmitter. Furthermore, the input circuit and the output circuit can be the same circuit, which is used as the input circuit and the output circuit at different times. This application does not limit the specific implementation of the processor and various circuits.

[0011] Fifthly, a processing apparatus is provided, including a processor and a memory. The processor is used to read instructions stored in the memory and to receive signals via a receiver and transmit signals via a transmitter to execute the method in any of the possible implementations of the first aspect described above.

[0012] Optionally, there may be one or more processors and one or more memories.

[0013] Alternatively, the memory can be integrated with the processor, or the memory can be set up separately from the processor.

[0014] In the specific implementation process, the memory can be a non-transitory memory, such as read-only memory (ROM), which can be integrated with the processor on the same chip or set on different chips. The embodiments of this application do not limit the type of memory or the way the memory and processor are set.

[0015] It should be understood that the relevant data interaction process, such as sending indication information, can be the process of outputting indication information from the processor, and receiving capability information can be the process of the processor receiving input capability information. Specifically, the processed output data can be output to the transmitter, and the input data received by the processor can come from the receiver. Here, the transmitter and receiver can be collectively referred to as a transceiver.

[0016] The processing device in the fifth aspect above can be a chip. The processor can be implemented in hardware or software. When implemented in hardware, the processor can be a logic circuit, integrated circuit, etc. When implemented in software, the processor can be a general-purpose processor that reads software code stored in memory. The memory can be integrated into the processor or located outside the processor and exist independently.

[0017] In a sixth aspect, a computer program product is provided, the computer program product comprising: a computer program (also referred to as code or instructions), which, when run, causes a computer to perform the method in any of the possible implementations of the first aspect described above.

[0018] In a seventh aspect, a computer-readable storage medium is provided that stores a computer program (also referred to as code or instructions) that, when executed on a computer, causes the computer to perform the methods in any of the possible implementations of the first aspect described above. Attached Figure Description

[0019] Figure 1 This is a schematic diagram of the system architecture of the electronic device provided in the embodiments of this application;

[0020] Figure 2 This is a schematic flowchart illustrating a memory management method provided in an embodiment of this application;

[0021] Figure 3 This is a schematic flowchart illustrating a first specific example of the memory management method provided in the embodiments of this application;

[0022] Figure 4 This is a schematic flowchart illustrating a second specific example of the memory management method provided in the embodiments of this application;

[0023] Figure 5This is a schematic flowchart illustrating a third specific example of the memory management method provided in the embodiments of this application;

[0024] Figure 6 This is a schematic flowchart illustrating the fourth specific example of the memory management method provided in the embodiments of this application;

[0025] Figure 7 This is a schematic flowchart illustrating the fifth specific example of the memory management method provided in the embodiments of this application;

[0026] Figure 8 This is a schematic diagram of the memory management method provided in an embodiment of this application;

[0027] Figure 9 This is a schematic flowchart illustrating the sixth specific example of the memory management method provided in the embodiments of this application;

[0028] Figure 10 This is a schematic diagram of an electronic device for memory management provided in an embodiment of this application;

[0029] Figure 11 This is a schematic flowchart illustrating the seventh specific example of the memory management method provided in the embodiments of this application;

[0030] Figure 12 This is a schematic block diagram of a memory management device provided in an embodiment of this application;

[0031] Figure 13 This is a schematic block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0032] The technical solutions in this application will now be described with reference to the accompanying drawings.

[0033] To facilitate a clear description of the technical solutions in the embodiments of this application, the terms "first" and "second" are used in the embodiments of this application to distinguish identical or similar items with essentially the same function and effect. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and the terms "first" and "second" are not necessarily different.

[0034] It should be noted that, in this application, the words "exemplarily" or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "exemplarily" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of words such as "exemplarily" or "for example" is intended to present the relevant concepts in a specific manner.

[0035] Furthermore, "at least one" refers to one or more, while "more than one" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can mean: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, and c can mean: a, or b, or c, or a and b, or a and c, or b and c, or a, b, and c, where a, b, and c can be single or multiple.

[0036] To make the objectives and technical solutions of this application clearer and more intuitive, the memory management methods, apparatus, devices, and storage media provided in the embodiments of this application will be described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.

[0037] As electronic devices become increasingly feature-rich, the demands on RAM also rise. Currently, memory management techniques can optimize memory usage, improving the smoothness of electronic device operation and enhancing the user experience.

[0038] However, the above methods are inflexible. For example, current memory optimization is usually achieved through a single memory management operation, which may lead to situations where it cannot meet or support special scenarios with large memory demands in a timely manner.

[0039] This application provides a memory management method, apparatus, device, and storage medium. Electronic devices can perform memory management operations when in a memory management scenario. These memory management operations can include at least two of the following: process cleanup, garbage collection, and compression. This allows the electronic device to release as much memory as possible by performing these memory management operations. The process cleanup operation has a higher priority than the garbage collection and compression operations, and the garbage collection operation has a higher priority than the compression operation. When performing these memory management operations, the electronic device can execute at least two of the above-mentioned memory management operations in descending order of priority. This avoids the additional overhead of performing garbage collection and / or compression operations on the running process of the executable process cleanup operation, and / or performing compression operations on the running process of the executable garbage collection operation. This achieves highly flexible memory management, improves memory management efficiency, and reduces memory management overhead.

[0040] The electronic devices involved in the embodiments of this application may be mobile phones, watches, laptops, handheld computers, mobile internet devices (MIDs), personal computers (PCs), wearable devices, virtual reality (VR) devices, augmented reality (AR) devices, wireless terminals in self-driving vehicles, wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, personal digital assistants (PDAs), etc., but the embodiments of this application are not limited to these.

[0041] For example, Figure 1 This is a schematic diagram of the system architecture of an electronic device provided in an embodiment of this application.

[0042] like Figure 1 As shown, the electronic device includes a processor 110, a transceiver 120, and a display unit 170. The display unit 170 may include a display screen.

[0043] Optionally, the electronic device may also include a memory 130. The processor 110, transceiver 120, and memory 130 can communicate with each other via internal connections to transfer data. The memory 130 stores computer programs, and the processor 110 retrieves and runs the computer programs from the memory 130. The processor 110 and memory 130 can be combined into a single processing device, but more commonly they are independent components. The processor 110 executes the program code stored in the memory 130 to achieve the aforementioned functions. In specific implementations, the memory 130 can be integrated into the processor 110, or it can be independent of the processor 110.

[0044] In addition, to further enhance the functionality of the electronic device, it may also include one or more of an input unit 160 and a sensor 101.

[0045] Optionally, the above-mentioned electronic device may also include a power supply 150 for providing power to various devices or circuits in the electronic device.

[0046] Understandable, Figure 1The operation and / or function of each module in the illustrated electronic device are respectively for implementing the corresponding processes in the following method embodiments. For details, please refer to the descriptions in the following method embodiments; detailed descriptions are omitted here to avoid repetition.

[0047] Understandable, Figure 1 The processor 110 in the illustrated electronic device may include one or more processing units, such as an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processing unit (NPU). These different processing units may be independent devices or integrated into one or more processors.

[0048] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0049] Understandable, Figure 1The power supply 150 shown provides power to the processor 110, memory 130, display unit 170, input unit 160, and transceiver 120. The transceiver 120 provides solutions for wireless communication applications in electronic devices, including wireless local area networks (WLANs) (such as Wireless Fidelity (Wi-Fi) networks), Bluetooth (BT), Global Navigation Satellite System (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. The transceiver 120 can be one or more devices integrating at least one communication processing module. The display unit 170 is used to display images, videos, etc. The display unit 170 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a mini-LED, a micro-LED, a quantum dot light-emitting diode (QLED), etc. The memory 130 can be used to store computer executable program code, which includes instructions. The memory 130 can include a program storage area and a data storage area. The program storage area can store the operating system, at least one application program required for a function, etc. The data storage area can store data created during the use of the electronic device, etc. Furthermore, the memory 130 can include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc. The processor 110 performs various functional applications and data processing of the electronic device by executing instructions stored in the memory 130 and / or instructions stored in the memory set in the processor.

[0050] Figure 2 This is a schematic flowchart of a memory management method 200 provided in an embodiment of this application. Figure 2 As shown, the method 200 may include the following steps:

[0051] S201, when the electronic device is in a memory management scenario, memory management operations are performed on the electronic device in descending order of priority. The memory management operations include at least two of the following: process cleanup operation, garbage collection operation, and compaction operation; wherein, the priority of the process cleanup operation is higher than the priority of the garbage collection operation and the compaction operation, and the priority of the garbage collection operation is higher than the priority of the compaction operation.

[0052] Memory management scenarios can be understood as those that trigger electronic devices to perform memory management operations. Electronic devices can perform these operations within these scenarios to optimize memory usage and improve user experience.

[0053] In some embodiments, the memory management scenario described above can be a scenario where the electronic device has a large memory requirement, or it can be a scenario set by the user that requires memory management.

[0054] In some embodiments, the memory management scenarios described above may include at least one of the following: game scenarios, camera scenarios, electronic device power-on scenarios, deep hibernation scenarios, and preset memory optimization scenarios.

[0055] Memory management operations, including process cleanup, are used to shut down, terminate, or optimize processes in electronic devices that are no longer needed or consume excessive system resources (such as CPU time and memory), thereby freeing up system resources and improving system performance and responsiveness. The aforementioned process is the basic unit for resource allocation and scheduling by the operating system; each running program or task in an electronic device exists as one or more processes.

[0056] Memory management operations include garbage collection, which is used to detect and reclaim memory that is no longer used by the program, thereby freeing up memory resources and avoiding problems such as memory leaks and memory overflows.

[0057] Memory management operations include compression operations used to compress processes whose swap space usage is less than a threshold, and to swap the compressed data to the swap space to free up memory resources.

[0058] In some embodiments, memory management operations may include at least two of the processes cleanup, garbage collection, and compaction operations described above. In other words, in the memory management scenario described above, the electronic device can perform at least two of the processes cleanup, garbage collection, and compaction operations to free up memory space.

[0059] In one possible scenario, the memory management operations described above include process cleanup operations, whereby the electronic device can acquire a running process (i.e., a process) and clean it up to release the memory occupied by the running process, which may include at least one foreground process and / or background process.

[0060] For example, if there are background processes running on an electronic device without the user's knowledge, these background processes will continue to run and occupy memory. The electronic device can clean up these background processes in a memory management scenario to free up memory and make more memory space available for large programs that need to run. Alternatively, when running game applications or graphics processing applications, the electronic device can clean up background processes such as browsers and music players so that the aforementioned game applications or graphics processing applications can obtain more memory resources, thereby improving running speed and responsiveness.

[0061] In one possible scenario, the above memory management operations include garbage collection operations. The electronic device can acquire the running process and clean up the target content corresponding to the running process to release the memory occupied by the target content corresponding to the running process. The target content can be understood as content not referenced by any variable. The running process can include at least one foreground process and / or background process.

[0062] Optionally, the garbage collection priority of the target content corresponding to the background process is higher than that of the target content corresponding to the foreground process.

[0063] In one possible scenario, the memory management operation described above includes a compression operation. The electronic device can acquire a running process and compress the processes in the running process whose swap space usage is less than a threshold to obtain a compressed running process. The compressed running process is then swapped from memory to the swap space to release the memory occupied by the running process. The running process may include at least one foreground process and / or a background process.

[0064] It should be understood that, in addition to performing multiple operations such as process cleanup, garbage collection, and compression in memory management scenarios to free up a large amount of memory, electronic devices can also perform these multiple operations in order of priority to avoid additional overhead.

[0065] In some embodiments, process cleanup operations may have a higher priority than garbage collection and compaction operations to avoid the additional overhead incurred by the electronic device performing garbage collection and / or compaction operations on the running process that is capable of performing process cleanup operations.

[0066] For example, if memory management operations include process cleanup and garbage collection, the electronic device can perform process cleanup first and then garbage collection in a memory management scenario. This avoids performing garbage collection on a running process first and then cleaning up the process again by performing process cleanup.

[0067] For example, if memory management operations include process cleanup and compression operations, the electronic device can perform the process cleanup operation first and then the compression operation in a memory management scenario. This avoids performing a compression operation on the running process first, and then performing a process cleanup operation again to clean up the running process that has undergone compression.

[0068] For example, if memory management operations include process cleanup, garbage collection, and compaction, the electronic device can perform process cleanup first, followed by garbage collection and compaction, in a memory management scenario. This avoids performing garbage collection and compaction on the running process first, and then cleaning up the running process again by performing process cleanup.

[0069] In some embodiments, the garbage collection operation may have a higher priority than the compaction operation to avoid the additional overhead of the electronic device performing a compaction operation on the basis of the garbage collection operation.

[0070] For example, if the above memory management operations include garbage collection and compaction, the electronic device can perform garbage collection first and then compaction in a memory management scenario. This avoids performing compaction on the running process first and then performing garbage collection again to clean up the target content corresponding to the compressed running process.

[0071] In some embodiments, the greater the memory requirement of an electronic device, the more operations can be performed in a memory management scenario to free up more memory. In other words, the electronic device can determine the aforementioned memory management operations based on its memory requirements.

[0072] For example, if an electronic device determines that the memory requirement is greater than or equal to a memory requirement threshold, it can sequentially perform process cleanup, garbage collection, and compaction operations in descending order of priority to maximize memory release and meet the current large memory requirement. Alternatively, if an electronic device determines that the memory requirement is less than the memory requirement threshold, it can perform two of the following operations in descending order of priority to release memory and meet the current small memory requirement.

[0073] In some embodiments, the lower the current load of the electronic device, the more operations it can perform in a memory management scenario to free up more memory. In other words, the electronic device can determine the aforementioned memory management operations based on its current load.

[0074] For example, if the current load is determined to be less than a load threshold, the electronic device can perform process cleanup, garbage collection, and compaction operations in descending order of priority to maximize memory release and meet the current large memory demand. Alternatively, if the current load is determined to be greater than or equal to the load threshold, the electronic device can perform two of the following operations in descending order of priority: process cleanup, garbage collection, and compaction, to avoid increasing the current load of the electronic device by performing all of the above operations while releasing memory and meeting the current memory demand.

[0075] In some embodiments, the electronic device may also determine the above-mentioned memory management operations based on memory requirements and current load.

[0076] For example, when an electronic device determines that the memory requirement is greater than or equal to a memory requirement threshold and the current load is less than a load threshold, it can sequentially perform process cleanup, garbage collection, and compaction operations in descending order of priority to maximize memory release while taking into account the load and meet the current large memory requirement.

[0077] For example, when an electronic device determines that the memory requirement is greater than or equal to a memory requirement threshold and the current load is greater than or equal to a load threshold, it can sequentially execute two of the following operations in descending order of priority: process cleanup, garbage collection, and compaction, in order to maximize memory release while taking into account the load and meet the current memory requirement.

[0078] For example, an electronic device may also perform at least two of the following operations in descending order of priority: process cleanup, garbage collection, and compaction, when it is determined that the memory requirement is less than the memory requirement threshold and the current load is less than the load threshold, in order to release memory while taking into account the load and meet the current memory requirement.

[0079] For example, an electronic device may also perform two of the following operations in descending order of priority: process cleanup, garbage collection, and compaction, when it is determined that the memory requirement is less than the memory requirement threshold and the current load is greater than or equal to the load threshold, in order to release memory while taking into account the load and meet the current memory requirement.

[0080] It should be understood that different operations result in different loads. When performing two of the above-mentioned process cleanup, garbage collection, and compression operations, the electronic device can also select different two of the process cleanup, garbage collection, and compression operations based on the current load.

[0081] For example, if the load generated by releasing memory through process cleanup is less than the load generated by releasing memory through garbage collection, and the load generated by releasing memory through garbage collection is less than the load generated by releasing memory through compaction, then when the current load of the electronic device is greater than or equal to the load threshold, process cleanup and garbage collection can be performed in descending order of priority to release memory, thereby minimizing the load on memory release and reducing the impact of excessive load on device performance. Alternatively, if the electronic device determines that the current load is less than the load threshold, it can also perform at least two of the following operations in descending order of priority to release memory and meet memory requirements: process cleanup, garbage collection, and compaction.

[0082] In this application, an electronic device can perform memory management operations when it is in a memory management scenario. These memory management operations can include at least two of the following: process cleanup, garbage collection, and compaction. This allows the electronic device to release as much memory as possible by performing these memory management operations. The process cleanup operation has a higher priority than the garbage collection and compaction operations, and the garbage collection operation has a higher priority than the compaction operation. When performing these memory management operations, the electronic device can execute at least two of the above-mentioned memory management operations in descending order of priority. This avoids the additional overhead of performing garbage collection and / or compaction operations on the running process of the process cleanup operation, and / or performing compaction operations on the running process of the garbage collection operation. This achieves highly flexible memory management, improves memory management efficiency, and reduces memory management overhead.

[0083] In some embodiments, when in a memory management scenario and the electronic device is determined to meet the memory management conditions, the electronic device performs the above-mentioned memory management operations in descending order of priority.

[0084] Figure 3 This is a schematic flowchart of a memory management method 300 provided in an embodiment of this application. Figure 3 As shown, the method 300 may include the following steps:

[0085] S301 indicates that the system is in a memory management scenario.

[0086] Memory management scenarios can be understood as the situations that trigger electronic devices to perform memory management operations. Electronic devices can perform these operations within these scenarios to optimize memory and improve user experience. These memory management scenarios can be those where the electronic device has a significant memory requirement, or they can be scenarios where the user has set up memory management to be performed.

[0087] In some embodiments, the memory management scenarios described above may include at least one of a game scenario, a camera scenario, an electronic device power-on scenario, a deep hibernation scenario, and a preset memory optimization scenario. An electronic device can determine whether it is in a memory management scenario by detecting at least one of the above scenarios.

[0088] S302, determine whether the electronic device meets the memory management conditions based on the first reference data.

[0089] In some embodiments, the first reference data includes at least one of processor load data, processor temperature data, and application running data. The processor load data indicates the processor's load, such as parent-child changes over a period of time; the processor temperature data indicates the processor's temperature, such as temperature changes over a period of time; and the application running data indicates the application scenario currently running on the electronic device, such as the status of the currently running application.

[0090] Correspondingly, the above memory management conditions include at least one of the following: the processor load is less than the load threshold; the processor temperature is less than the temperature threshold; the application scenario currently running on the electronic device does not belong to the preset application scenario.

[0091] In some embodiments, the preset application scenario can be a scenario where a heavy-load application is running. Such heavy-load applications could be live streaming applications, game applications, etc., so that electronic devices can avoid memory management operations in this preset application scenario, thus avoiding increased load and reducing the problem of poor user experience such as lag caused by excessive load.

[0092] S303, if the electronic device meets the memory management conditions based on the first reference data, memory management operations are performed on the electronic device in descending order of priority. The memory management operations include at least two of the following: process cleanup operation, garbage collection operation, and compression operation; wherein the priority of the process cleanup operation is higher than the priority of the garbage collection operation and the compression operation, and the priority of the garbage collection operation is higher than the priority of the compression operation.

[0093] Optionally, following S302, the electronic device may also refrain from any operation if it is determined, based on the first reference data, that the electronic device does not meet the memory management conditions. Alternatively, the following steps may be performed:

[0094] S304, if the electronic device does not meet the memory management conditions based on the first reference data collected in the first time, the system determines whether the newly collected first reference data meets the memory management conditions at intervals of a second preset time within a first preset time period, wherein the second preset time period is less than the first preset time period.

[0095] S305, based on the first reference data collected for the Nth time within the first preset time period, if it is determined that the electronic device meets the above memory management conditions, memory management operations are performed on the electronic device in order of priority from high to low.

[0096] For example, the first preset duration is 30 minutes, the second preset duration is 10 seconds, and the memory management operation includes process cleanup. If, based on the first collected reference data, the electronic device is determined not to meet the memory management conditions, the electronic device can determine, every 10 seconds within the 30 minutes, whether the newly collected first reference data meets the memory management conditions. See details below. Figure 4 .

[0097] Figure 4 This is a schematic flowchart of a memory management method 400 provided in an embodiment of this application. Figure 4 As shown, the method 400 may include the following steps:

[0098] S401 indicates that the system is in a memory management scenario.

[0099] S402 determines whether the electronic device meets the memory management conditions.

[0100] The electronic device can determine whether it meets the memory management conditions based on the first reference data. For specific details, please refer to the description in the above embodiments; to avoid repetition, it will not be repeated here.

[0101] S403, if it determines that the electronic device meets the memory management conditions, obtains the running process.

[0102] Optionally, the running process here can be any running process other than at least one of the following types of running processes in the electronic device: running processes with a priority greater than the priority threshold, foreground running processes, and running processes that are perceptible to the user.

[0103] S404, clean up running processes to release the memory occupied by running processes.

[0104] Alternatively, following S402 above, the electronic device may also perform the following operations:

[0105] S405, if it is determined that the electronic device does not meet the memory management conditions, the interval is a second preset time.

[0106] For example, the electronic device can be spaced 10 seconds apart.

[0107] S406, determine whether the total interval duration exceeds the first preset duration.

[0108] For example, determine whether the duration of the cumulative interval exceeds 30 minutes.

[0109] like Figure 4 As shown, if the total interval duration does not exceed the first preset duration, the electronic device can execute the above S402 again, that is, determine again whether the electronic device meets the memory management conditions.

[0110] Here, based on the new first reference data, it is determined whether the electronic device meets the memory management conditions. If the electronic device meets the memory management conditions, S403 and S404 are executed. Alternatively, if the electronic device does not meet the memory management conditions, S405 and S406 are executed, that is, after another second preset time interval, and without exceeding the first preset time interval, the above-mentioned S402 is executed.

[0111] Optionally, if the total interval exceeds a first preset duration, the current memory management process can be terminated.

[0112] In this embodiment, when the electronic device is in a memory management scenario and it is determined that the memory management conditions are met, the aforementioned memory management operations are performed on the electronic device in descending order of priority. For example, if the memory management conditions include the processor load being less than a load threshold, the processor temperature being less than a temperature threshold, or the application scenario currently running on the electronic device not belonging to at least one of the preset application scenarios, the electronic device can perform memory management operations when the memory management conditions are determined to be met. This avoids performing memory management operations when the processor load is greater than or equal to the load threshold, the processor temperature is greater than or equal to the temperature threshold, or the application scenario currently running on the electronic device belongs to at least one of the preset application scenarios. This reduces the probability of excessive processor load, excessive temperature, and lag in preset application scenarios, thus improving the flexibility of memory management.

[0113] In some embodiments, when the electronic device is currently in a screen-on state and it is determined that the electronic device meets the memory management conditions, memory management operations are performed on the electronic device in descending order of priority.

[0114] Figure 5 This is a schematic flowchart of a memory management method 500 provided in an embodiment of this application. Figure 5 As shown, the method 500 may include the following steps:

[0115] S501 indicates that the system is in a memory management scenario.

[0116] S502 determines whether the electronic device is currently in a screen-on state based on screen status information.

[0117] S503, when the electronic device is currently in a screen-on state, determines whether the electronic device meets the memory management conditions based on the first reference data.

[0118] S504, if the electronic device meets the memory management conditions based on the first reference data, obtain the target object corresponding to any operation in the memory management operation.

[0119] In some embodiments, the target object corresponding to the process cleanup operation includes the running process of the electronic device, the target object corresponding to the garbage collection operation includes the target content of the running process of the electronic device, the target content is content not referenced by any variable, and the target object corresponding to the compression operation includes the running process of the electronic device whose swap space usage is less than a threshold.

[0120] S505, according to a preset time interval, perform corresponding operations on the target objects in batches to release the memory occupied by the target objects.

[0121] Optionally, following S502, if the electronic device is currently in a screen-off state, the electronic device may also perform the following steps:

[0122] S506 performs memory management operations on electronic devices in descending order of priority.

[0123] Optionally, following S503, if the electronic device determines, based on the first reference data, that the electronic device does not meet the memory management conditions, the following steps may be performed:

[0124] S507, within a first preset time period, at intervals of a second preset time period, determine whether the newly collected first reference data meets the memory management conditions, wherein the second preset time period is less than the first preset time period.

[0125] S508, based on the first reference data collected for the Nth time within the first preset time period, if it is determined that the electronic device meets the memory management conditions, the memory management operation is performed on the electronic device in order of priority from high to low.

[0126] The following is combined with Figure 6 Taking memory management operations including compression operations as an example, the memory management method provided in this application is described.

[0127] Figure 6 This is a schematic flowchart of a memory management method 600 provided in an embodiment of this application. Figure 6 As shown, the method 600 may include the following steps:

[0128] S601 indicates that the system is in a memory management scenario.

[0129] S602 determines whether an electronic device is currently in a screen-on state based on screen status information.

[0130] S603 determines whether the electronic device meets the memory management conditions when the screen is currently on.

[0131] S604: If the electronic device meets the memory management requirements, obtain the running processes whose swap space usage is less than the threshold.

[0132] S605, according to a preset time interval, compress the running processes whose swap space usage is less than the threshold in batches, and swap the compressed running processes whose swap space usage is less than the threshold to the swap space.

[0133] S606, if it is determined that the electronic device does not meet the memory management conditions, the interval is a second preset time.

[0134] S607, determine whether the total interval duration exceeds the first preset duration.

[0135] like Figure 6 As shown, following the above S607, if the total interval duration does not exceed the first preset duration, the electronic device can execute the above S602 again, that is, determine again whether the electronic device is currently in the screen-on state, and if it is determined that it is currently in the screen-on state, execute S603 again, that is, whether the electronic device meets the memory management conditions.

[0136] It should be understood that the electronic device can determine whether it meets the memory management conditions based on the new first reference data, and if it is determined that the electronic device meets the memory management conditions, S604 and S605 are executed. Alternatively, if the electronic device does not meet the memory management conditions, S606 and S607 are executed, that is, after another second preset time interval, and without exceeding the first preset time interval, the above-mentioned S602 is executed.

[0137] Optionally, following the above S607, if it is determined that the total interval exceeds the first preset duration, the current memory management process is terminated.

[0138] Alternatively, following S602 above, if the electronic device is currently in a state where the screen is off, the electronic device may also perform the following steps:

[0139] S608: Get running processes whose swap space usage is less than the threshold.

[0140] S609, Compress the running processes whose swap space usage is less than the threshold, and swap the compressed running processes whose swap connection usage is less than the threshold from memory to swap space, so as to release the memory occupied by the running processes whose swap space usage is less than the threshold.

[0141] Optionally, following S502 above, if the electronic device determines that the memory management conditions are met, the electronic device may also perform corresponding operations on the target object in batches, without adhering to a preset time interval. This operation can be a low-load operation for releasing memory during memory management, such as garbage collection. For details, see [link to relevant documentation]. Figure 7 .

[0142] The following is combined with Figure 7 Taking memory management operations, including garbage collection operations, as an example, the memory management method provided in this application is described.

[0143] Figure 7 This is a schematic flowchart of a memory management method 700 provided in an embodiment of this application. Figure 7 As shown, the method 700 may include the following steps:

[0144] S701 detects that it is in a memory management scenario.

[0145] S702 determines whether an electronic device is currently in a screen-on state based on screen status information.

[0146] S703 determines whether the electronic device meets memory management conditions when the screen is currently on.

[0147] S704 obtains the running process after determining that the electronic device meets the memory management requirements.

[0148] S705, clean up the target content corresponding to the running process to release the memory occupied by the target content of the running process, which is the content referenced by any variable.

[0149] Alternatively, following S703 above, the electronic device may also perform the following steps:

[0150] S706, if it is determined that the electronic device does not meet the memory management conditions, the interval is a second preset time.

[0151] S707, determine whether the total interval duration exceeds the first preset duration.

[0152] like Figure 7As shown, if the total interval duration does not exceed the first preset duration, the electronic device can execute S702 again, that is, determine again whether the electronic device is currently in the screen-on state, and if it is determined that it is currently in the screen-on state, execute S703 again, that is, whether the electronic device meets the memory management conditions.

[0153] It should be understood that the electronic device can determine whether it meets the memory management conditions based on the new first reference data, and if it is determined that the electronic device meets the memory management conditions, S704 and S705 are executed. Alternatively, if the electronic device does not meet the memory management conditions, S706 and S707 are executed, that is, after another second preset time interval, and if the total interval time does not exceed the first preset time interval, the above-mentioned S702 is executed.

[0154] Optionally, if the total interval duration exceeds the first preset duration, the current memory management process can be terminated.

[0155] Optionally, following S702 above, if the electronic device is not currently in a screen-on state, the electronic device can also execute S704 and S705 above. For details, please refer to the above step description. To avoid repetition, they will not be repeated here.

[0156] Figure 8 This is a schematic diagram of a memory management method provided in an embodiment of this application. Figure 8 As shown, electronic devices can perform memory management in memory management scenarios to achieve memory release. Memory management scenarios can include active scenarios and passive scenarios.

[0157] For example, active scenes may include game scenes, camera scenes, and preset memory optimization scenes (such as one-click memory optimization scenes).

[0158] For example, passive scenarios include deep sleep scenarios (such as doze scenarios) and electronic device power-on scenarios (hereinafter referred to as power-on scenarios).

[0159] It should be understood that the details of memory management differ between active and passive scenarios; see [link to relevant documentation] for details. Figure 9 .

[0160] Figure 9 This is a schematic flowchart of a memory management method 900 provided in an embodiment of this application. Figure 8 As shown, the method 900 may include the following steps:

[0161] S901 indicates that the system is in a memory management scenario.

[0162] S902, determine whether it is an active scenario.

[0163] S903 determines whether an electronic device is in a screen-on state when it is determined that it is not in an active scene.

[0164] S904 determines whether the electronic device meets the memory management conditions when the screen is on.

[0165] S905: If the electronic device meets the memory management conditions, obtain the target object corresponding to the memory management operation.

[0166] S906, according to a preset time interval, perform corresponding operations on the target objects in batches to release the memory occupied by the target objects.

[0167] S907, if it is determined that the electronic device does not meet the memory management conditions, a second preset time interval is elapsed.

[0168] S908, determine whether the total interval duration exceeds the first preset duration.

[0169] like Figure 9 As shown, if the total interval duration exceeds the first preset duration, the electronic device can execute the above S903 again.

[0170] Optionally, following S903 above, if it is determined that the electronic device is not in a screen-on state, the electronic device may also perform the following steps:

[0171] S909, obtain the target object corresponding to the memory management operation.

[0172] S910, perform the corresponding operation on the target object to release the memory occupied by the target object.

[0173] Optionally, following S902 above, if it is determined that it is not an active scenario, the electronic device can also execute S909 and S910 above.

[0174] Figure 10 A schematic diagram of an electronic device 1000 provided in this application is shown below. Figure 10 As shown, the electronic device 1000 includes a resource management module 1001 and a memory management module 1002. The resource management module 1001 may include a load monitoring module 1011, a temperature monitoring module 1012, and an application operation monitoring module 1013. The resource management module 1001 can monitor the processor load and collect processor load data through the load monitoring module 1011, monitor the processor temperature and collect processor temperature data through the temperature monitoring module 1012, and monitor application operation and collect application operation data through the application operation monitoring module 1013.

[0175] like Figure 10As shown, the resource management module 1001 can send first reference data to the memory management module 1002 in real time or periodically. This first reference data may include at least one of processor load data, processor temperature data, and application running data. Correspondingly, the memory management module 1002 can receive the first reference data from the resource management module 1001, and when the electronic device 1000 is in the memory management acquisition state, it determines whether the electronic device 1000 meets the memory management conditions based on the first reference data. If the electronic device 1000 meets the memory management conditions, it performs memory management operations on the electronic device 1000 in descending order of priority.

[0176] like Figure 10 As shown, the memory management module 1002 includes a process cleanup module 1021, a garbage collection module 1022, and a compression module 1023. The memory compression module 1023 can select at least two of the process cleanup module 1021, garbage collection module 1022, and compression module 1023 to perform corresponding operations based on memory requirements and / or current load.

[0177] As shown in 11, specific memory management operations can be triggered by the configured identifier.

[0178] S1101, determine whether the first identifier is carried.

[0179] The first identifier is the identifier corresponding to the process cleanup operation.

[0180] S1102, with the first identifier carried, perform process cleanup operation.

[0181] If clearFlag == true, it means that the first flag is carried; conversely, if clearFlag == false, it means that the first flag is not carried, that is, the process cleanup operation is not performed.

[0182] like Figure 11 As shown, after executing S1102 or determining that the first identifier is not carried, the following steps can be performed:

[0183] S1103, determine whether a second identifier is carried.

[0184] S1104, Perform waste collection operation while carrying a second identifier.

[0185] If gcFlag == true, it means that the second flag is carried; conversely, if gcFlag == false, it means that the second flag is not carried, i.e., garbage collection is not performed.

[0186] like Figure 11As shown, after executing S1104 or determining that the first identifier is not carried, the following steps can be performed:

[0187] S1105, determine whether a third identifier is carried.

[0188] S1104, performing compression operation while carrying a third identifier.

[0189] For example, compressFlag == true indicates that a third flag is carried, and correspondingly, compressFlag == false indicates that no third flag is carried, that is, no compression operation is performed.

[0190] When carrying the first identifier, the memory management module 1002 can perform cleanup operations on the running processes of the application APP (such as APP1, APP2, etc.) through the process cleanup module 1021.

[0191] With the second identifier carried, the memory management module 1002 can clean up the target memory of the APP's running process through the garbage collection module 1022.

[0192] When carrying a third identifier, the memory management module 1002 can compress running processes of the APP whose swap space usage is less than a threshold through the compression module 1023, and swap them to the compressed space to release memory.

[0193] It should be understood that the various embodiments described above can also be coupled to each other, and this application does not limit this. Furthermore, the sequence number of each process does not imply the order of execution; the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0194] The above text combines Figures 1 to 11 The present application describes in detail the memory management method of its embodiments. The following will be combined with... Figure 12 and Figure 13 This application describes in detail the memory management apparatus of the embodiments thereof.

[0195] Figure 12 This application illustrates a memory management device 1200, applied to an electronic device. The memory management device 1200 includes a memory management module 1201, which performs memory management operations on the electronic device in a memory management scenario, according to a descending priority order. These memory management operations include at least two of the following: process cleanup, garbage collection, and compression. The process cleanup operation has a higher priority than both the garbage collection and compression operations, and the garbage collection operation has a higher priority than the compression operation.

[0196] Optionally, the memory management module 1201 is used to: when the electronic device is in a memory management scenario and it is determined that the electronic device meets the memory management conditions, perform the memory management operation on the electronic device in descending order of priority.

[0197] Optionally, the memory management module 1201 is configured to: when the electronic device is in a memory management scenario and the electronic device meets the memory management conditions based on first reference data, perform the memory management operation on the electronic device in descending order of priority; wherein, the first reference data includes at least one of processor load data, processor temperature data, and application running data, the processor load data is used to indicate the processor load, the processor temperature data is used to indicate the processor temperature, the application running data is used to indicate the application scenario currently running on the electronic device, and the memory management conditions include at least one of the following: the processor load is less than a load threshold, the processor temperature is less than a temperature threshold, and the application scenario currently running on the electronic device does not belong to a preset application scenario.

[0198] Optionally, the memory management module 1201 is configured to: use the first reference data as the reference data collected for the Nth time, where N is an integer greater than 1; when the electronic device is in a memory management scenario and it is determined based on the first collected reference data that the electronic device does not meet the memory management conditions, determine whether the newly collected first reference data meets the memory management conditions every second preset time interval within a first preset time interval, where the second preset time interval is less than the first preset time interval; and when it is determined based on the first reference data collected for the Nth time within the first preset time interval that the electronic device meets the memory management conditions, perform memory management operations on the electronic device in descending order of priority.

[0199] Optionally, the memory management module 1201 is used to: when it is determined that the electronic device meets the memory management conditions, obtain the target object corresponding to any operation in the memory management operation; and perform the corresponding operation on the target object in batches according to a preset time interval to release the memory occupied by the target object; wherein, the target object corresponding to the process cleanup operation includes the running process of the electronic device, the target object corresponding to the garbage collection operation includes the target content of the running process of the electronic device, the target content being content not referenced by any variable, and the target object corresponding to the compression operation includes the running process of the electronic device whose swap space usage is less than a threshold.

[0200] Optionally, the memory management module 1201 is used to: determine whether the electronic device is currently in a screen-on state based on screen status information when the electronic device is in a memory management scenario; and perform memory management operations on the electronic device in order of priority from high to low when the electronic device is currently in a screen-on state and it is determined that the electronic device meets the memory management conditions.

[0201] Optionally, the memory management module 1201 is used to: perform memory management operations on the electronic device in descending order of priority when it is determined that the electronic device is not currently in a screen-on state.

[0202] Optionally, the memory management module 1201 is used to perform memory management operations on the electronic device in descending order of priority based on memory requirements and / or current load.

[0203] Optionally, the memory management module 1201 is configured to: perform process cleanup, garbage collection, and compression operations on the electronic device in descending order of priority when the memory requirement is greater than or equal to the memory requirement threshold and the current load is less than the load threshold; or, perform two of the process cleanup, garbage collection, and compression operations on the electronic device in descending order of priority when the memory requirement is greater than or equal to the memory requirement threshold and the current load is greater than or equal to the load threshold; or, perform at least two of the process cleanup, garbage collection, and compression operations on the electronic device in descending order of priority when the memory requirement is less than the memory requirement threshold and the current load is less than the load threshold; or, perform two of the process cleanup, garbage collection, and compression operations on the electronic device in descending order of priority when the memory requirement is less than the memory requirement threshold and the current load is greater than or equal to the load threshold.

[0204] Optionally, the memory management triggering scenarios include at least one of the following: game scenario, camera scenario, electronic device power-on scenario, deep hibernation scenario, and preset memory optimization scenario.

[0205] It should be understood that the memory management device 1200 here is embodied in the form of a functional module. The term "module" here can refer to an application-specific integrated circuit (ASIC), electronic circuitry, a processor (e.g., a shared processor, a proprietary processor, or a group processor, etc.) and memory for executing one or more software or firmware programs, integrated logic circuitry, and / or other suitable components supporting the described functions. In an alternative example, those skilled in the art will understand that the memory management device 1200 can be specifically the electronic device in the above embodiments, or the functions of the electronic device in the above embodiments can be integrated into the memory management device 1200. The memory management device 1200 can be used to execute the various processes and / or steps corresponding to the electronic device in the above method embodiments; to avoid repetition, these will not be described again here. The memory management device 1200 has the function of implementing the corresponding steps executed by the electronic device in the above method; the above functions can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions. In the embodiments of this application, Figure 12 The memory management device 1200 can also be a chip or a chip system, such as a system on chip (SoC).

[0206] Figure 13 An electronic device 1300 according to an embodiment of this application is shown. The electronic device 1300 includes a processor 1301, a memory 1302, a communication interface 1303, and a bus 1304. The memory 1302 stores instructions, and the processor 1301 executes the instructions stored in the memory 1302. The processor 1301, memory 1302, and communication interface 1303 are interconnected via the bus 1304.

[0207] The processor 1301 is configured to: when the electronic device is in a memory management scenario, perform memory management operations on the electronic device in descending order of priority. The memory management operations include at least two of the following: process cleanup, garbage collection, and compaction. The process cleanup operation has a higher priority than the garbage collection and compaction operations, and the garbage collection operation has a higher priority than the compaction operation.

[0208] It should be understood that the electronic device 1300 may specifically be the electronic device in the above embodiments, or the functions of the electronic device in the above embodiments may be integrated into the electronic device 1300. The electronic device 1300 may be used to execute the various steps and / or processes corresponding to the electronic device in the above method embodiments. Optionally, the memory 1302 may include read-only memory and random access memory, and provide instructions and data to the processor 1301. A portion of the memory 1302 may also include non-volatile random access memory. For example, the memory 1302 may also store device type information. The processor 1301 may be used to execute instructions stored in the memory, and when the processor executes the instructions, the processor 1301 may execute the various steps and / or processes corresponding to the electronic device in the above method embodiments. It should be understood that in the embodiments of this application, the processor may be a central processing unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor. In implementation, the steps of the above methods can be completed by integrated logic circuits in the processor's hardware or by instructions in software form. The steps of the methods disclosed in the embodiments of this application can be directly implemented by a hardware processor, or by a combination of hardware and software modules in the processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory, and the processor executes the instructions in the memory, combining with its hardware to complete the steps of the above methods. To avoid repetition, detailed descriptions are not provided here. Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application. Those skilled in the art will readily understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood from the several embodiments provided in this application that the disclosed systems, devices, and methods can be implemented in other ways.For example, the device embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some interfaces, indirect couplings, or communication connections between devices or units, and may be electrical, mechanical, or other forms. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs. Additionally, the functional units in the various embodiments of this application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. If the function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk. The above descriptions are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A memory management method, characterized in that, Applied to electronic devices, the method includes: When the electronic device is in a memory management scenario, memory management operations are performed on the electronic device in descending order of priority. The memory management operations include at least two of the following: process cleanup, garbage collection, and compression. The process cleanup operation has a higher priority than the garbage collection operation and the compression operation, and the garbage collection operation has a higher priority than the compression operation.

2. The method according to claim 1, characterized in that, When the electronic device is in a memory management scenario, performing memory management operations on the electronic device in descending order of priority includes: When the electronic device is in the memory management scenario and it is determined that the electronic device meets the memory management conditions, the memory management operation is performed on the electronic device in descending order of priority.

3. The method according to claim 2, characterized in that, When the electronic device is in the memory management scenario and it is determined that the electronic device meets the memory management conditions, the memory management operation is performed on the electronic device in descending order of priority, including: When the electronic device is in the memory management scenario and the electronic device meets the memory management conditions based on the first reference data, the memory management operation is performed on the electronic device in order of priority from high to low. The first reference data includes at least one of processor load data, processor temperature data, and application running data. The processor load data is used to indicate the processor load, the processor temperature data is used to indicate the processor temperature, and the application running data is used to indicate the application scenario currently running on the electronic device. The memory management conditions include at least one of the following: the processor load is less than a load threshold, the processor temperature is less than a temperature threshold, and the application scenario currently running on the electronic device does not belong to a preset application scenario.

4. The method according to claim 3, characterized in that, The first reference data is the reference data collected for the Nth time, where N is an integer greater than 1. The step of performing the memory management operation on the electronic device in descending order of priority, when the electronic device is in the memory management scenario and the electronic device meets the memory management conditions based on the first reference data, includes: When the electronic device is in the memory management scenario, and it is determined based on the first reference data collected for the first time that the electronic device does not meet the memory management conditions, the new first reference data collected is determined every second preset time interval within the first preset time interval to determine whether it meets the memory management conditions, wherein the second preset time interval is less than the first preset time interval; Based on the first reference data collected for the Nth time within the first preset time period, if it is determined that the electronic device meets the memory management conditions, the memory management operation is performed on the electronic device in order of priority from high to low.

5. The method according to any one of claims 2 to 4, characterized in that, If the electronic device meets the memory management conditions, memory management operations are performed on the electronic device in descending order of priority, including: If the electronic device is determined to meet the memory management conditions, the target object corresponding to any operation in the memory management operation is obtained; According to a preset time interval, corresponding operations are performed on the target object in batches to release the memory occupied by the target object; The target objects corresponding to the process cleanup operation include the running processes of the electronic device; the target objects corresponding to the garbage collection operation include the target content of the running processes of the electronic device, wherein the target content is content not referenced by any variables; and the target objects corresponding to the compression operation include the running processes of the electronic device whose swap space usage is less than a threshold.

6. The method according to claim 2, characterized in that, When the electronic device is in a memory management scenario and it is determined that the electronic device meets the memory management conditions, the memory management operation is performed on the electronic device in descending order of priority, including: When the electronic device is in a memory management scenario, it is determined whether the electronic device is currently in a screen-on state based on the screen status information. When the electronic device is currently in the screen-on state and it is determined that the electronic device meets the memory management conditions, the memory management operation is performed on the electronic device in descending order of priority.

7. The method according to claim 6, characterized in that, The method further includes: If it is determined that the electronic device is not currently in the screen-on state, the memory management operation is performed on the electronic device in descending order of priority.

8. The method according to claim 1, characterized in that, When the electronic device is in a memory management scenario, memory management operations are performed on the electronic device in descending order of priority, including: Based on memory requirements and / or current load, memory management operations are performed on the electronic device in descending order of priority.

9. The method according to claim 8, characterized in that, The process of performing memory management operations on the electronic device based on memory requirements and / or current load, in descending order of priority, includes: If the memory requirement is greater than or equal to the memory requirement threshold, and the current load is less than the load threshold, the program cleanup operation, the garbage collection operation, and the compression operation are performed on the electronic device in descending order of priority; or, If the memory requirement is greater than or equal to the memory requirement threshold, and the current load is greater than or equal to the load threshold, then, in descending order of priority, the electronic device is subjected to two of the following operations: the process cleanup operation, the garbage collection operation, and the compression operation; or, If the memory requirement is less than the memory requirement threshold and the current load is less than the load threshold, at least two of the following operations are performed on the electronic device in descending order of priority: the process cleanup operation, the garbage collection operation, and the compression operation; or, When the memory requirement is less than the memory requirement threshold and the current load is greater than or equal to the load threshold, the electronic device is subjected to two of the following operations in descending order of priority: the process cleanup operation, the garbage collection operation, and the compression operation.

10. The method according to claim 1, characterized in that, The memory management scenarios include at least one of the following: game scenario, camera scenario, electronic device boot scenario, deep hibernation scenario, and preset memory optimization scenario.

11. A memory management device, characterized in that, The memory management device, used in electronic devices, includes: The memory management module is configured to perform memory management operations on the electronic device in descending order of priority when the electronic device is in a memory management scenario. The memory management operations include at least two of the following: process cleanup, garbage collection, and compression. The process cleanup operation has a higher priority than the garbage collection operation and the compression operation, and the garbage collection operation has a higher priority than the compression operation.

12. An electronic device, characterized in that, It includes a processor and a memory, the memory being used to store code instructions; the processor being used to execute the code instructions to perform the method as described in any one of claims 1 to 10.

13. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 10.