Memory management method and related apparatus

By monitoring and processing the idle status of the dedicated memory pool, the problem of ineffective utilization of idle memory in the dedicated memory pool is solved, realizing efficient memory reuse and management, and improving the utilization rate and management efficiency of system memory resources.

WO2026237643A1PCT designated stage Publication Date: 2026-11-19HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2026/091026
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2025-05-15
Filing Date
2026-04-16
Publication Date
2026-11-19

AI Technical Summary

Technical Problem

In existing technologies, there is free memory in the dedicated memory pool but insufficient general memory pool, which leads to ineffective utilization of system memory resources. Furthermore, the operating system's memory reclamation accuracy is low, and invalid reclamation is prone to occur, making it difficult to solve the problem of insufficient memory.

Method used

By monitoring the idle status of the dedicated memory pool, timely operations such as memory migration, memory reclamation, or memory elimination are performed to reuse the idle memory of the dedicated memory pool for general purposes, thereby improving memory utilization and providing targeted solutions when memory is insufficient.

Benefits of technology

It enables the reuse of dedicated memory, improves memory utilization, ensures that the dedicated memory pool meets actual needs, avoids memory shortages, and improves the efficiency and accuracy of memory management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2026091026_19112026_PF_FP_ABST
    Figure CN2026091026_19112026_PF_FP_ABST
Patent Text Reader

Abstract

A memory management method, which is applied to an execution device comprising a dedicated memory pool and a general memory pool. Idle memory in the dedicated memory pool is reused to provide general-purpose memory, such that the reuse of a dedicated memory is achieved, thereby improving a memory utilization rate. In addition, a memory use situation of the dedicated memory pool is continuously monitored during the use of the dedicated memory pool. When it is monitored that the idle memory in the dedicated memory pool is insufficient, operations such as memory migration, memory reclaim or memory checking and removal are executed on the dedicated memory pool in time, so as to increase the idle memory in the dedicated memory pool, thereby ensuring that the dedicated memory pool can meet actual memory use requirements, and avoiding the situation where the dedicated memory is insufficient due to the reuse of the dedicated memory pool as much as possible.
Need to check novelty before this filing date? Find Prior Art

Description

A memory management method and related apparatus

[0001] This application claims priority to Chinese Patent Application No. 202510632981.X, filed on May 15, 2025, entitled “A Memory Management Method and Related Apparatus”, the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application relates to the field of computer technology, and in particular to a memory management method and related apparatus. Background Technology

[0003] In a computer, memory provides temporary storage space for the operating system and various applications. Taking applications as an example, all running applications in a computer need to be executed through memory. Data and instructions in applications are temporarily stored in memory so that the processor can quickly read and write data from memory, thus ensuring the efficient operation of the applications.

[0004] In some scenarios, the operating system kernel divides physical memory into dedicated memory pools and general-purpose memory pools for memory management. The difference between dedicated and general-purpose memory is that memory in a dedicated memory pool can only be used for specific purposes. For example, when the operating system uses the Contiguous Memory Allocator (CMA) mechanism, it sets up a dedicated CMA memory pool. When a driver needs to allocate contiguous memory, it specifies that memory should be allocated from the CMA pool. The CMA mechanism ensures that a memory region is specifically reserved for allocating contiguous memory, improving the efficiency of contiguous memory allocation.

[0005] Dedicated memory pools reserve specific memory areas for specific purposes, ensuring efficient allocation and use of memory for those purposes. However, the setup of dedicated memory pools also introduces new problems. Specifically, because dedicated memory pools are specifically designed to provide memory for specific uses, in some cases, there may be a situation where the dedicated memory pool has a large amount of free memory, while the general-purpose memory pool cannot meet the demand, resulting in inefficient utilization of system memory resources. Summary of the Invention

[0006] This application provides a memory management method and related apparatus that can improve the utilization rate of memory resources.

[0007] Firstly, a memory management method is provided that can be applied to the operating system of an execution device. The memory management method includes: the operating system obtaining the memory free status of a first memory pool, wherein the first memory pool is a dedicated memory pool used to provide memory for a specific purpose (i.e., dedicated memory), and the first memory pool, when having free memory, can be reused to provide general-purpose memory (i.e., non-dedicated ordinary memory) other than the intended purpose.

[0008] When the memory availability meets preset conditions, the operating system performs memory processing operations on the first memory pool to increase the free memory in the first memory pool. The memory processing operations include at least one of memory migration, memory reclamation, and memory cleanup. Memory migration involves moving data in the general-purpose memory of the first memory pool to the second memory pool. The second memory pool is a general-purpose memory pool and is used only to provide general-purpose memory.

[0009] In this solution, by reusing the free memory in a dedicated memory pool for general-purpose use, dedicated memory reuse is achieved, improving memory utilization. Furthermore, the memory usage of the dedicated memory pool is continuously monitored during its operation. When insufficient free memory is detected, operations such as memory migration, memory reclamation, or memory cleanup are performed promptly to increase the free memory in the dedicated memory pool. This ensures that the dedicated memory pool can meet actual memory usage needs and minimizes the possibility of dedicated memory shortages due to memory pool reuse.

[0010] In one possible implementation, the preset conditions include memory migration conditions, and the memory processing operations include memory migration.

[0011] If memory is available and the memory migration conditions are met, the operating system, based on the memory management structure of the first memory pool, traverses the migrateable memory pages in the first memory pool, where the migrateable memory pages are for general purposes. Then, the operating system migrates the data in the migrateable memory pages to the second memory pool.

[0012] In other words, when the free memory in the first memory pool is insufficient, the operating system can specifically find the reused memory pages in the first memory pool (i.e., memory pages reused for general purposes) and migrate the reused memory pages to the second memory pool, a general memory pool, thereby freeing up more free memory in the first memory pool and ensuring that there is enough dedicated memory available for use.

[0013] In one possible implementation, the preset conditions include memory reclamation conditions, and the memory processing operations include memory reclamation.

[0014] When memory is idle and the conditions for memory reclamation are met, the operating system traverses the Least Recently Used (LRU) list to specifically identify reclaimable memory pages in the first memory pool. Then, the operating system performs memory reclamation on these reclaimable pages.

[0015] In this solution, by specifically checking the free memory status in the first memory pool, and triggering the reclamation of only reclaimable memory pages in the first memory pool when the free memory in the first memory pool is insufficient, more free memory can be freed up in the first memory pool, while ensuring the efficiency of memory reclamation.

[0016] In one possible implementation, the preset conditions include memory detection conditions, and the memory processing operations include memory detection.

[0017] If the memory availability meets the conditions for memory termination, the operating system identifies at least one process occupying memory in the first memory pool and terminates that process. That is, the operating system does not terminate processes that only occupy memory in the second memory pool.

[0018] In other words, the operating system does not kill any process that arbitrarily occupies memory, but rather selectively kills processes that occupy memory in the first memory pool. This ensures that after killing these processes, free up memory in the first memory pool, improving the efficiency of memory killing and avoiding ineffective killing.

[0019] In one possible implementation, when performing a kill operation on at least one process, the operating system sorts the at least one process according to its kill priority, obtaining a sorting result. Then, the operating system kills the at least one process sequentially based on the sorting result. If multiple processes with the same kill priority exist in the sorting result, the processes are killed sequentially based on their memory usage in the first memory pool.

[0020] In other words, when performing memory cleanup, the operating system prioritizes killing high-priority processes (usually those with lower execution priority or those whose deletion would have little impact on user experience) to reduce the impact of process cleanup on system stability. Furthermore, when processes have the same priority, the operating system prioritizes killing processes that consume more memory in the first memory pool, thereby maximizing the memory gains from process cleanup and improving the efficiency of memory cleanup.

[0021] In one possible implementation, the operating system can obtain memory allocation requests that request the allocation of memory from a first memory pool. The operating system determines whether to allocate memory from the first memory pool based on the intended use of the requested memory and the available free memory in the first memory pool. That is, the operating system may set different priorities for memory allocation requests with different purposes. When the available free memory in the first memory pool does not change significantly, higher-priority memory allocation requests are more likely to be responded to, while lower-priority memory allocation requests are less likely to be responded to.

[0022] This solution combines the intended use of the memory requested in the memory allocation request with the available free memory in the first memory pool to determine whether to respond to the memory allocation request. When there is not much free memory left in the first memory pool, it can refuse to allocate memory for general purposes, thereby ensuring that the remaining free memory in the first memory pool is allocated to the target purpose first, and ensuring the effective allocation of dedicated memory.

[0023] In one possible implementation, the operating system can determine a first memory allocation threshold based on the intended use of the memory requested in the memory allocation request. If the free memory in the first memory pool is not lower than the first memory allocation threshold, the operating system determines to allocate memory from the first memory pool based on the memory allocation request; if the free memory in the first memory pool is lower than the first memory allocation threshold, the operating system determines not to allocate memory from the first memory pool.

[0024] In one possible implementation, the memory requested by the memory allocation request is for general purposes. The first memory allocation line is determined based on the migration cost and / or lifecycle stability of the memory requested by the memory allocation request. The level of the first memory allocation line is positively correlated with the migration cost and negatively correlated with the lifecycle stability.

[0025] In other words, the higher the migration cost of the memory requested by a memory allocation request, the higher the first memory allocation threshold, meaning the memory allocation request is more difficult to respond to; conversely, the lower the migration cost of the memory requested by a memory allocation request, the lower the first memory allocation threshold, meaning the memory allocation request is easier to respond to. Furthermore, the higher the lifecycle stability of the memory requested by a memory allocation request, the lower the first memory allocation threshold, meaning the memory allocation request is easier to respond to.

[0026] In one possible implementation, the operating system can calculate the total amount of free physical memory, which includes a first memory pool and a second memory pool. The total amount of free memory is obtained by performing a weighted sum of the free memory amounts in the first and second memory pools, with the weight of the free memory amount in the first memory pool being less than the weight of the free memory amount in the second memory pool. When the total amount of free memory meets the memory reclamation criteria, the operating system performs memory reclamation on the physical memory.

[0027] In other words, besides triggering memory reclamation specifically for the first memory pool, the operating system can typically also perform memory reclamation on the physical memory of the entire system (i.e., the first and second memory pools) to ensure sufficient free memory in the system. Furthermore, when the system memory includes different types of memory pools, the operating system assigns lower weights to memory pools with limited usage when calculating the total amount of free memory in the system. This effectively represents the actual amount of usable memory remaining in the system, thus facilitating accurate triggering of system memory reclamation and ensuring the normal use of system memory.

[0028] In one possible implementation, the operating system periodically triggers the acquisition of memory freeness in the first memory pool.

[0029] In one possible implementation, the dedicated memory pool includes a microkernel memory pool or a CMA memory pool.

[0030] In a second aspect, a memory management device is provided, comprising: an acquisition module for acquiring the memory free status of a first memory pool, the first memory pool being a dedicated memory pool used to provide memory for a specific purpose, and capable of reusing the first memory pool to provide general-purpose memory other than the specific purpose when it has free memory; and a processing module for performing memory processing operations on the first memory pool to increase the free memory in the first memory pool when the memory free status meets preset conditions; wherein the memory processing operations include at least one of memory migration, memory reclamation, and memory elimination, wherein memory migration is used to migrate data on general-purpose memory in the first memory pool to a second memory pool, the second memory pool being a general-purpose memory pool used only to provide general-purpose memory.

[0031] In one possible implementation, the preset conditions include memory migration conditions, the memory processing operations include memory migration, and the processing module is specifically used to: when the memory migration conditions are met due to memory idleness, based on the memory management structure of the first memory pool, traverse the migrateable memory pages in the first memory pool, the purpose of which is general purpose; and migrate the data in the migrateable memory pages to the second memory pool.

[0032] In one possible implementation, the preset conditions include memory reclamation conditions, the memory processing operations include memory reclamation, and the processing module is specifically used to: determine the reclaimable memory pages in the first memory pool by traversing the LRU list when the memory is idle and the memory reclamation conditions are met; and perform memory reclamation on the reclaimable memory pages.

[0033] In one possible implementation, the preset conditions include memory killing conditions, the memory processing operations include memory killing, and the processing module is specifically used to: determine at least one process occupying memory in the first memory pool when the memory is idle and the memory killing conditions are met; and perform a killing operation on at least one process.

[0034] In one possible implementation, the processing module is specifically used to: sort at least one process according to its killing priority to obtain a sorting result; kill at least one process sequentially based on the sorting result; wherein, when there are multiple processes with the same killing priority in the sorting result, the multiple processes are killed sequentially based on the memory usage of the processes in the first memory pool.

[0035] In one possible implementation, the acquisition module is further configured to acquire a memory allocation request, which requests the allocation of memory in the first memory pool; the processing module is further configured to determine whether to allocate memory in the first memory pool based on the purpose of the memory requested in the memory allocation request and the free memory in the first memory pool.

[0036] In one possible implementation, the processing module is specifically configured to: determine a first memory allocation line based on the purpose of the memory requested in the memory allocation request; if the free memory in the first memory pool is not lower than the first memory allocation line, determine to allocate memory in the first memory pool based on the memory allocation request; and if the free memory in the first memory pool is lower than the first memory allocation line, determine not to allocate memory in the first memory pool.

[0037] In one possible implementation, the memory requested by the memory allocation request is for general purposes. The first memory allocation line is determined based on the migration cost and / or lifecycle stability of the memory requested by the memory allocation request. The level of the first memory allocation line is positively correlated with the migration cost and negatively correlated with the lifecycle stability.

[0038] In one possible implementation, the processing module is further configured to: calculate the total amount of free physical memory, the physical memory including a first memory pool and a second memory pool, the total amount of free memory being obtained by performing a weighted summation of the free memory amounts of the first memory pool and the second memory pool, the weight corresponding to the free memory amount of the first memory pool being less than the weight corresponding to the free memory amount of the second memory pool; and perform memory reclamation on the physical memory when the total amount of free memory meets the memory reclamation conditions.

[0039] In one possible implementation, the acquisition module obtains the memory free status of the first memory pool periodically.

[0040] In one possible implementation, the dedicated memory pool includes a microkernel memory pool or a CMA memory pool.

[0041] A third aspect of this application provides a memory management apparatus, which may include a processor and a memory coupled together. The memory stores program instructions, and when the program instructions stored in the memory are executed by the processor, the method described in the first aspect or any implementation thereof is implemented. For details regarding the steps of the various possible implementations of the first aspect executed by the processor, please refer to the first aspect; further details will not be repeated here.

[0042] The fourth aspect of this application provides a computer-readable storage medium storing a computer program that, when run on a computer, causes the computer to perform the method of any implementation of the first aspect described above.

[0043] The fifth aspect of this application provides a circuit system including a processing circuit configured to perform the method of any implementation of the first aspect described above.

[0044] The sixth aspect of this application provides a computer program product that, when run on a computer, causes the computer to perform any implementation of the first aspect described above.

[0045] A seventh aspect of this application provides a chip system including a processor for implementing the functions involved in any implementation of the first aspect described above, such as processing data and / or information involved in the methods described above. In one possible design, the chip system also includes a memory for storing necessary program instructions and data. This chip system may be composed of chips or may include chips and other discrete devices.

[0046] The beneficial effects of the second to seventh aspects mentioned above can be referred to the introduction of the first aspect above, and will not be repeated here. Attached Figure Description

[0047] Figure 1 is a schematic diagram of a microkernel architecture provided in this application;

[0048] Figure 2 is a schematic diagram of a system architecture provided in this application;

[0049] Figure 3 is a flowchart illustrating a memory management method provided in this application;

[0050] Figure 4 is a schematic diagram of a memory migration operation provided in this application;

[0051] Figure 5 is a schematic diagram of a memory migration triggered and executed for the first memory pool according to this application;

[0052] Figure 6 is a schematic diagram of a process for performing memory reclamation on the first memory pool provided in this application;

[0053] Figure 7 is a flowchart illustrating the sequential execution of different memory processing operations on a first memory pool according to this application.

[0054] Figure 8 is a schematic diagram of memory allocation lines corresponding to different purposes when applying for memory pages according to this application;

[0055] Figure 9 is a schematic diagram of a memory allocation process provided in this application;

[0056] Figure 10 is a comparative schematic diagram of a memory allocation process provided in this application;

[0057] Figure 11 is a comparative diagram of a micro-core memory pool and a general-purpose memory pool provided in this application;

[0058] Figure 12 is a schematic diagram of a memory management device provided in this application;

[0059] Figure 13 is a structural schematic diagram of an execution device provided in this application;

[0060] Figure 14 is a schematic diagram of the structure of a computer-readable storage medium provided in this application. Detailed Implementation

[0061] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.

[0062] The terms "first," "second," "third," "fourth," etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in a sequence other than that illustrated or described herein.

[0063] Furthermore, the terms “comprising” and “having”, and any variations thereof, are intended to cover non-exclusive inclusion, such that a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to such process, method, product, or apparatus.

[0064] For ease of understanding, some technical terms involved in the embodiments of this application will be introduced below.

[0065] (1) Memory pool

[0066] A memory pool is essentially a block of memory divided by the operating system into physical memory segments. A memory pool typically comprises multiple memory pages. Specifically, the operating system manages memory at the page level and can divide the available physical memory into multiple memory pools based on different usage scenarios or purposes. For each memory page, the information about which memory pool it belongs to is stored in the operating system's physical page management structure (page struct).

[0067] (2) Memory allocation

[0068] Memory allocation refers to the process by which the operating system allocates memory for tasks such as threads or processes.

[0069] Specifically, when the operating system needs to allocate memory, it specifies the corresponding memory pool based on the current physical memory usage and calls the physical memory allocator using the allocation flag of the specified memory pool. The physical memory allocator retrieves a specified size of free physical memory (at the memory page level) from the corresponding memory pool and returns the identifier of the free physical memory to the caller (e.g., using a physical address or a pointer to a page struct as the memory identifier). In some memory allocation scenarios, the operating system does not need to specify a specific memory pool, i.e., it does not need to specify the allocation flag of the memory pool. In this case, the physical memory allocator traverses all memory pools, retrieves a specified size of free physical memory, and returns the memory identifier. After allocating the memory, the physical memory allocator changes the status of the allocated memory in the physical page management structure from free to non-free and updates the memory management information of the memory pool, completing the memory allocation.

[0070] (3) Memory release

[0071] Memory release refers to the process where, when a user no longer needs a particular memory location, they invoke the operating system's memory release interface to free up that memory. The physical memory allocator in the operating system uses the memory identifier (such as the memory's virtual or physical address) passed by the releaser to locate the corresponding physical page management structure, and further identifies the memory pool. Then, the physical memory allocator changes the status recorded in the physical page management structure to free and updates the memory management information of the corresponding memory pool, completing the memory release.

[0072] (4) Memory reclamation

[0073] Memory reclamation is the process by which the operating system automatically manages and optimizes memory resources. When the system's physical memory is insufficient, the operating system uses a series of mechanisms to reclaim unused memory pages and reallocate them to processes or tasks that need them. When the amount of available free memory in the system falls below a certain level, the operating system's reclamation mechanism is triggered, reclaiming memory in use even when the memory user has not explicitly released it. Then, when the user accesses the same memory again, the operating system will request new free memory for the user to use. Therefore, memory reclamation is transparent to the user; the silent background memory reclamation and reallocation process is not visible to the user, thus enhancing the flexibility of system memory management.

[0074] (5) Memory Scan

[0075] Memory killing refers to the operating system releasing memory resources occupied by certain processes by closing them, thereby freeing up some free memory. When performing memory killing, the operating system will prioritize the processes based on comprehensive process information, and then kill the processes in order according to their priority.

[0076] (6) Memory migration

[0077] Memory migration refers to the operating system performing functions such as memory defragmentation by migrating (i.e., changing) the virtual memory mappings to physical memory. During memory migration, the operating system first allocates a new free physical page, then performs the migration operation, changing all virtual memory mappings of the original physical page to map to the new physical page. After the virtual memory mappings are modified, the operating system releases the original physical page, completing the memory migration.

[0078] (7) Operating System Kernel

[0079] The operating system kernel is primarily used to implement fundamental system functions such as virtual and physical memory allocation and management, address space mapping management, inter-process communication, process management, file systems, networking, and device drivers. Generally, the operating system kernel provides memory mapping, unmapping, and remapping interfaces to perform operations such as mapping, unmapping, and remapping specified virtual and physical addresses with specified permissions.

[0080] (8) Monolithic kernel

[0081] A monolithic kernel is a type of operating system kernel; the Linux kernel, Unix kernel, and Windows kernel are all monolithic kernels. A monolithic kernel means that all operating system kernel functional components reside in the same address space, are not isolated from each other, and implement all operating system kernel functions holistically.

[0082] (9) Microkernel

[0083] A microkernel is a type of operating system kernel. Currently, some smartphone kernels (such as the HarmonyOS kernel and the iOS kernel) are microkernels. A microkernel refers to an operating system kernel where different functional components are independent entities, isolated from each other. Each functional component is called a system service of the microkernel operating system, and exists as a process within the microkernel. Furthermore, the core system service responsible for memory management is generally called the exkernel.

[0084] For example, please refer to Figure 1, which is a schematic diagram of a microkernel architecture provided in this application. As shown in Figure 1, the microkernel architecture includes entities such as a microkernel, an outer kernel, and system services. The microkernel is mainly responsible for tasks such as address space isolation (e.g., handling memory-mapped requests), inter-process communication (IPC), and scheduling. The outer kernel is mainly responsible for tasks such as memory management and process management. The outer kernel and other system services such as network and drivers exist as independent processes.

[0085] The memory management module in the outer kernel receives memory allocation requests from upper-layer applications and other system services, allocates physical memory for them from the physical memory allocator, and allocates page table memory for mapping physical memory. Then, the memory management module calls the memory mapping interface provided by the microkernel, requesting the microkernel to complete the specific memory mapping operation, along with the virtual address, physical address, page table address, permissions, and other parameters to be mapped. When the outer kernel receives a memory release (demapping) request from an upper-layer application, it passes the virtual address and size specified by the upper-layer application to the microkernel, which then performs the demapping operation. After the microkernel successfully returns, the outer kernel returns the physical page corresponding to the physical address to the physical memory allocator and updates the metadata status of the physical page.

[0086] Microkernel memory (such as page table memory) is generally allocated by the outer kernel, and the allocated page table memory, etc., is passed to the microkernel as parameters in interfaces such as memory mapping. When the microkernel memory lifecycle changes (allocation or release), the outer kernel notifies the microkernel, which then checks and updates the physical page metadata status.

[0087] (10) Memory Management

[0088] Memory management refers to the process by which the memory management module in the operating system kernel manages the actual physical memory resources of a device through a physical memory allocator, allocating them to applications, the kernel, or system services as needed. Generally, physical memory is managed in units of 4 kilobytes (KB). That is, each 4KB of physical memory is called a memory page. The operating system kernel maintains a page management data structure for each memory page to record information such as the page type and its lifecycle state (free or non-free), and performs memory allocation and memory mapping management based on this information.

[0089] (11) Contiguous Memory Allocator (CMA)

[0090] Contiguous Memory Management (CMA) is a contiguous memory management mechanism used to allocate contiguous memory. Specifically, both monolithic and microkernels use CMA to efficiently allocate physically contiguous memory for device drivers, as device drivers typically require physically contiguous memory addresses. CMA maintains a dedicated CMA memory pool. When contiguous memory needs to be allocated, the driver specifies the allocation flag for the CMA memory pool, calls the kernel's physical memory allocation interface, and specifies that memory should be allocated from the CMA pool. CMA ensures that a memory region is specifically reserved for allocating contiguous memory, improving the efficiency of contiguous memory allocation.

[0091] (12) Anonymous Page

[0092] Anonymous pages are memory pages that are not associated with disk files and are typically used to store dynamic data during process execution.

[0093] (13) File Page

[0094] A file page is a memory page in memory that is associated with a disk file; it is usually a cache or mapping of file content.

[0095] (14) Least Recently Used (LRU) algorithm

[0096] The LRU (Least Recently Used) algorithm is a commonly used page replacement algorithm for managing page replacement in memory. The core idea of ​​LRU is based on the principle of temporal locality, meaning that recently accessed data will likely be accessed again in the future. LRU is implemented by maintaining a sequential linked list (i.e., an LRU list, usually a doubly linked list). Nodes in the LRU list are arranged in the order they were accessed. The most recently accessed data node is moved to the head of the list, while the least recently used data node is placed at the tail. When memory is full, the operating system can replace the least recently used node at the tail of the LRU list, thus reclaiming memory.

[0097] Currently, dedicated memory pools reserve specific memory areas for specific purposes, ensuring efficient allocation and use of memory for those purposes. However, the setup of dedicated memory pools also introduces new problems. Specifically, because dedicated memory pools are specifically designed to provide memory for specific uses, in some cases, there may be a situation where the dedicated memory pool has a large amount of free memory, while the general-purpose memory pool cannot meet the demand, resulting in inefficient utilization of system memory resources. For example, under the CMA mechanism, if the CMA memory pool has free memory while the general-purpose memory pool is full, the operating system may still experience allocation failures when allocating general-purpose memory, leading to inefficient use of free memory within the operating system.

[0098] Furthermore, the applicant's research revealed that current memory management technologies treat physical memory uniformly, without distinguishing between dedicated memory pools and general-purpose memory pools. For example, when a dedicated memory allocation fails within the dedicated memory pool, the operating system triggers memory reclamation. However, this reclamation applies to the entire physical memory, meaning that in most cases, the reclaimed memory resides primarily in the general-purpose memory pool, rendering it unusable. In other words, the operating system's memory reclamation accuracy is low, prone to ineffective memory reclamation, and fails to effectively address memory shortages.

[0099] In view of this, this application provides a memory management method that reuses the free memory of a dedicated memory pool for general-purpose memory, thereby achieving dedicated memory reuse and improving memory utilization. Furthermore, during the use of the dedicated memory pool, its memory usage is continuously monitored. When insufficient free memory is detected in the dedicated memory pool, operations such as memory migration, memory reclamation, or memory cleanup are performed promptly to increase the free memory in the dedicated memory pool. This ensures that the dedicated memory pool can meet actual memory usage needs and minimizes the possibility of insufficient dedicated memory due to dedicated memory pool reuse.

[0100] Specifically, under the CMA mechanism, because the CMA memory pool has a relatively small scope of use, only allocating corresponding contiguous memory for drivers, the impact of insufficient memory in the CMA memory pool is relatively small. However, for certain dedicated memory pools, the impact of insufficient memory in the dedicated memory pool can be more significant, greatly affecting the user experience.

[0101] For example, in a microkernel architecture, because the microkernel itself needs to be isolated from other microkernel system services, the operating system sets up a microkernel memory pool to specifically allocate microkernel memory, such as page table memory or kernel object memory. Furthermore, the general-purpose memory pool is not allowed to allocate microkernel memory; it can only allocate general-purpose memory such as file pages and anonymous pages. In this way, microkernel memory can be restricted to a specific address range, allowing for kernel state maintenance optimization based on the microkernel-specific memory pool (i.e., the microkernel only needs to maintain the microkernel memory state, not the general memory state), thereby improving memory management efficiency and microkernel isolation capabilities. Clearly, in a microkernel architecture, the microkernel memory pool is specifically provided for the microkernel; therefore, insufficient memory in the microkernel memory pool will affect the normal operation of the microkernel, causing significant impact. Therefore, in this situation, the memory management method provided in this application can continuously monitor the memory idle status of the dedicated memory pool and promptly perform operations such as memory migration, memory reclamation, or memory cleanup on the dedicated memory pool, thereby increasing the free memory in the dedicated memory pool and ensuring that the dedicated memory pool can meet actual memory usage needs, avoiding insufficient memory in the dedicated memory pool that would affect the normal operation of the system.

[0102] Please refer to Figure 2, which is a schematic diagram of a system architecture provided in this application. As shown in Figure 2, in the system architecture, the execution device 101 can be a terminal device such as a physical server, personal computer, laptop computer, smartphone, or tablet computer. The execution device 101 includes physical memory 102 and an operating system 103. The physical memory 102 includes a dedicated memory pool 1021 and a general-purpose memory pool 1022. The dedicated memory pool 1021 can be used to provide memory for a specific purpose, and the dedicated memory pool 1021 can also be reused to provide memory for general purposes.

[0103] During operation, the operating system 103 in the execution device 101 can execute the memory management method provided in this application to manage the dedicated memory pool 1021 and the general memory pool 1022, thereby ensuring that the memory resources in the physical memory can be effectively utilized.

[0104] Please refer to Figure 3, which is a flowchart illustrating a memory management method provided in this application. As shown in Figure 3, the execution process of this memory management method includes the following steps 301-302.

[0105] Step 301: Obtain the memory free status of the first memory pool. The first memory pool is a dedicated memory pool. The first memory pool is used to provide memory for a specific purpose, and when the first memory pool has free memory, it can be reused to provide memory for general purposes other than the specific purpose.

[0106] The memory management method provided in this application can be applied to an execution device that includes physical memory, wherein the physical memory of the execution device is divided into a first memory pool and a second memory pool. Furthermore, the execution entity of this memory management method can be the operating system within the execution device, specifically, the memory management module within the operating system.

[0107] The first memory pool is a dedicated memory pool within the execution device, specifically designed to provide memory for a specific purpose (i.e., the target purpose mentioned above). For example, the first memory pool could be a microkernel memory pool, specifically designed to provide memory for the microkernel (such as page table memory or kernel object memory). The target purpose of the memory provided by the first memory pool could be storing data generated by the microkernel, such as page tables or kernel objects. As another example, the first memory pool could be a CMA memory pool, specifically designed to provide contiguous memory for drivers; that is, the target purpose of the memory provided by the first memory pool could be storing contiguous data related to the driver.

[0108] Furthermore, besides providing memory for its intended purpose, the first memory pool can also be reused to provide general-purpose memory (i.e., non-dedicated ordinary memory) if it contains free memory. In this way, when the operating system receives a memory allocation request for ordinary memory, it can allocate some free memory from the first memory pool for use as ordinary memory. For example, the operating system can allocate memory from the first memory pool as file pages or anonymous pages, thereby providing general-purpose memory.

[0109] Optionally, the operating system in the execution device can periodically obtain the memory free status of the first memory pool to determine whether subsequent memory processing operations need to be performed on the first memory pool. That is, the operating system essentially periodically monitors the memory usage of the first memory pool to obtain information about its memory free status. This memory free status can indicate the size of the remaining free memory in the first memory pool, the proportion of the remaining free memory to the total memory of the first memory pool, and other information.

[0110] Of course, the operating system can also trigger the acquisition of the memory availability of the first memory pool when it receives a memory allocation request for the first memory pool, in order to confirm whether the free memory in the first memory pool can meet the amount of memory requested by the memory allocation request.

[0111] Step 302: When the memory idle situation meets the preset conditions, perform memory processing operations on the first memory pool to increase the free memory in the first memory pool; wherein, the memory processing operations include at least one of memory migration, memory reclamation and memory killing, and memory migration is to migrate the data on the general-purpose memory in the first memory pool to the second memory pool, the second memory pool is a general-purpose memory pool, and the second memory pool is only used to provide general-purpose memory.

[0112] After obtaining the memory free status of the first memory pool, the operating system in the execution device can determine whether the memory free status meets preset conditions, and thus determine whether memory processing operations need to be performed on the first memory pool. If the memory free status of the first memory pool meets the preset conditions, the operating system can assume that the remaining free memory in the first memory pool is low, and therefore the operating system needs to perform memory processing operations on the first memory pool to increase the free memory in it. If the memory free status of the first memory pool does not meet the preset conditions, the operating system can assume that the remaining free memory in the first memory pool is high, and therefore the operating system does not need to perform memory processing operations on the first memory pool.

[0113] The preset conditions can include one or more conditions. When the preset conditions include one condition, if the memory idle state of the first memory pool meets the preset condition, the operating system can perform one or more of the following operations on the first memory pool: memory migration, memory reclamation, and memory killing. If the preset conditions include multiple conditions, these multiple conditions can be conditions corresponding to memory migration, memory reclamation, and memory killing, respectively. Therefore, "the memory idle state of the first memory pool meets the preset conditions" can mean that the memory idle state meets any one of the multiple conditions, and the operating system can perform the operation corresponding to the met condition on the first memory pool. For example, if the memory idle state of the first memory pool meets the condition corresponding to memory migration, the operating system performs memory migration on the first memory pool; if the memory idle state of the first memory pool meets the condition corresponding to memory reclamation, the operating system performs memory reclamation on the first memory pool; if the memory idle state of the first memory pool meets the condition corresponding to memory killing, the operating system performs memory killing on the first memory pool.

[0114] It should be noted that in this application, the operating system may selectively monitor the memory free space of the first memory pool and perform memory processing operations specifically on the first memory pool, rather than performing memory processing operations on the entire physical memory of the execution device. In this way, the operating system performs targeted monitoring and processing on the first memory pool alone, ensuring that the free memory in the first memory pool is effectively utilized while guaranteeing that the first memory pool can quickly and effectively free up free memory when there is little remaining free memory, avoiding invalid memory processing operations, and ensuring the dedicated memory supply for the first memory pool.

[0115] Of course, if the operating system triggers the check of the first memory pool's free memory status upon receiving a memory allocation request, then the aforementioned condition of meeting the free memory status can mean that the free memory in the first memory pool is insufficient to meet the requirements of the memory allocation request. That is, the amount of free memory in the first memory pool is less than the amount of memory requested in the memory allocation request.

[0116] To facilitate understanding, the following section will detail the memory processing operations that the operating system can perform on the first memory pool.

[0117] In the first implementation method, the operating system performs memory processing operations on the first memory pool, including memory migration.

[0118] For example, when the memory freeness of the first memory pool meets the memory migration conditions, the operating system can traverse the migrateable memory pages in the first memory pool based on the memory management structure of the first memory pool, where the purpose of the migrateable memory pages is general-purpose. That is, the migrateable memory pages belong to the memory pool reused to provide general-purpose memory. Furthermore, the migrateable memory pages must be page types that support migration, and not page types that do not support migration (such as memory pages allocated to drivers). The memory management structure of the first memory pool records information about each memory page in the first memory pool, such as the page's state (free or non-free), page type, and whether the page is a reused memory page. Therefore, by traversing the memory management structure of the first memory pool, the operating system can determine the information of each memory page in the first memory pool, and thus determine the migrateable memory pages in the first memory pool.

[0119] Then, the operating system migrates the data in the migrateable memory pages to the second memory pool, thus completing the memory page migration.

[0120] In other words, when the free memory in the first memory pool is insufficient, the operating system can migrate the reused memory pages (i.e., memory pages reused for general purposes) of the first memory pool to the second memory pool, a general memory pool, thereby freeing up more free memory in the first memory pool.

[0121] Specifically, please refer to Figure 4, which is a schematic diagram of a memory migration process provided in this application. As shown in Figure 4, before the memory migration is performed, the used memory in the first memory pool includes two parts: one part is memory for the target purpose, and the other part is memory for general purposes. The used memory in the second memory pool only includes memory for general purposes. During the memory migration, the operating system migrates the memory for general purposes from the first memory pool to the second memory pool, thereby leaving only the memory for the target purpose in the first memory pool, thus freeing up more free memory in the first memory pool.

[0122] Optionally, the operating system may perform migration operations on all migrateable memory pages until all migrateable memory pages in the first memory pool have been migrated to the second memory pool or the free memory in the second memory pool can no longer accommodate more migrated data. Alternatively, the operating system may perform memory page migrations sequentially until the free memory in the first memory pool meets the requirements. For example, the operating system may trigger memory migration when the free memory in the first memory pool falls below the low migration threshold, and stop memory migration when the free memory in the first memory pool is not lower than the high migration threshold.

[0123] For example, please refer to Figure 5, which is a schematic diagram of triggering and executing memory migration for a first memory pool according to this application. As shown in Figure 5, for the first memory pool, when the operating system confirms that the current migration triggering conditions are met, that there is general-purpose memory in the first memory pool, and that there is sufficient free memory in the second memory pool, the operating system will perform memory migration for the first memory pool, thereby migrating the general-purpose memory in the first memory pool to the second memory pool. The migration conditions can specifically be synchronous migration conditions and asynchronous migration conditions. The synchronous migration condition is when a memory allocation failure event occurs in the first memory pool, that is, the free memory in the first memory pool is insufficient to meet the requirements of the memory allocation request. The asynchronous migration condition is when the operating system detects that the free memory in the first memory pool is below the memory low migration threshold. When the first memory pool meets either the synchronous migration condition or the asynchronous migration condition, the operating system will trigger the execution of memory migration.

[0124] After the operating system performs memory migration on the first memory pool, it will stop the migration if the migration stopping conditions are met. These conditions may include, for example, that the free memory in the first memory pool reaches the high migration threshold, that all general-purpose memory has been migrated, and that the free memory in the second memory pool is insufficient to accommodate any more data migrated from the first memory pool. The operating system can stop performing memory migration on the first memory pool when any of these conditions are met.

[0125] In the second implementation method, the operating system performs memory processing operations on the first memory pool, including memory reclamation.

[0126] For example, when the free memory situation in the first memory pool meets the memory reclamation conditions, the operating system uses the LRU list to determine the reclaimable memory pages in the first memory pool. Specifically, the memory reclamation conditions may be, for example, that the free memory in the first memory pool is below a pre-set low memory reclamation threshold (i.e., asynchronous reclamation conditions), or that a memory allocation failure occurs in the first memory pool (i.e., synchronous reclamation conditions). Since the LRU list records the least recently used memory pages in physical memory in a certain order, the operating system can sequentially find the least recently used memory pages based on the LRU list (e.g., starting from the tail of the LRU list to find the least recently used memory page), and obtain specific information about these memory pages (e.g., whether the memory page is in the first memory pool, and whether the memory page type is a type that supports reclamation), thereby determining the reclaimable memory pages in the first memory pool. That is, the operating system determines the reclaimable memory pages for the first memory pool to ensure that the reclaimed memory is from the first memory pool.

[0127] Then, the operating system performs memory reclamation on the reclaimable memory pages in the first memory pool. In other words, when the free memory in the first memory pool is insufficient, the operating system can reclaim the reclaimable memory pages in the first memory pool, thereby freeing up more free memory in the first memory pool.

[0128] Optionally, to reduce the impact of reclaiming too many memory pages, the operating system can sequentially perform reclamation operations on the reclaimable memory pages in the first memory pool until a stop reclamation condition is met. This stop reclamation condition could be, for example, that the free memory in the first memory pool is not lower than a pre-set memory high reclamation threshold.

[0129] For example, please refer to Figure 6, which is a schematic diagram of a memory reclamation process for a first memory pool provided in this application. As shown in Figure 6, the operating system can determine whether to trigger a memory reclamation condition by monitoring the free memory status of the first memory pool. For example, the operating system determines to trigger a memory reclamation condition when the free memory in the first memory pool is below the low reclamation threshold or when a memory allocation failure occurs in the first memory pool. After triggering the memory reclamation condition, the operating system traverses the LRU list, for example, starting from the tail of the LRU list and sequentially finding the least recently used memory page. For each memory page traversed, the operating system determines whether the memory page is located in the first memory pool and whether the memory page type is a type that supports reclamation. If the memory page is located in the first memory pool and supports reclamation, then the operating system performs reclamation on the memory page. After performing reclamation on the memory page, the operating system determines whether the first memory pool meets the stop reclamation condition, for example, whether the free memory in the first memory pool is not below the high reclamation threshold. If the first memory pool meets the stop reclamation condition, the operating system stops reclamation of the first memory pool; if the first memory pool does not meet the stop reclamation condition, the operating system continues to traverse the LRU list to continue reclamation of memory pages in the first memory pool.

[0130] Of course, if the operating system has already traversed the LRU list and reclaimed all memory pages that support reclamation, but the first memory pool has not yet met the conditions for stopping reclamation, the operating system will also stop reclamation of the first memory pool.

[0131] Furthermore, it should be noted that when the operating system receives a memory allocation request, if the memory type indicated by the memory allocation request is a type of memory that cannot be allocated in the first memory pool, and the memory pool that can execute the memory allocation request (such as the second memory pool) has insufficient free memory, the operating system will only trigger the reclamation of memory pages in the second memory pool when triggering memory reclamation, and will not trigger the reclamation of memory pages in the first memory pool.

[0132] That is, for the second memory pool, the operating system can also perform memory reclamation operations only on the memory in the second memory pool when the free memory in the second memory pool is insufficient, thereby achieving efficient reclamation of the memory in the second memory pool.

[0133] In the third implementation method, the operating system performs memory processing operations on the first memory pool, including memory scanning.

[0134] For example, if the free memory situation in the first memory pool meets the memory killing condition (e.g., the free memory in the first memory pool is below the memory low killing threshold), the operating system determines that at least one process is occupying memory in the first memory pool. Then, the operating system performs a killing operation on the process occupying at least one memory in the first memory pool. That is, for processes that only occupy memory in the second memory pool, the operating system does not kill these processes.

[0135] In other words, the operating system does not kill any process that arbitrarily occupies memory, but rather selectively kills processes that occupy memory in the first memory pool. This ensures that after killing these processes, free up memory in the first memory pool, improving the efficiency of memory killing and avoiding ineffective killing.

[0136] Optionally, to avoid excessive process deletion that could significantly impact normal system operation, the operating system can sort at least one process according to its deletion priority, obtaining a sorting result. Then, the operating system sequentially deletes at least one process based on the sorting result until a stopping condition is met (e.g., the free memory in the first memory pool is not lower than the high memory deletion threshold). If multiple processes with the same deletion priority exist in the sorting result, the operating system deletes these processes sequentially based on their memory usage in the first memory pool.

[0137] In other words, when performing memory cleanup, the operating system prioritizes killing high-priority processes (usually those with lower execution priority or those whose deletion would have little impact on user experience) to reduce the impact of process cleanup on system stability. Furthermore, when processes have the same priority, the operating system prioritizes killing processes that consume more memory in the first memory pool, thereby maximizing the memory gains from process cleanup and improving the efficiency of memory cleanup.

[0138] It should be noted that the three implementation methods described above can be independent. That is, as long as the memory freeness of the first memory pool meets the conditions corresponding to any one of the three implementation methods, the operating system can execute the memory processing operations (such as memory migration, memory reclamation, or memory cleanup) in that implementation method. Furthermore, in some cases, if the memory freeness of the first memory pool simultaneously meets the conditions corresponding to all three implementation methods, the operating system will execute all three implementation methods at the same time to free up more free memory for the first memory pool.

[0139] Of course, in some examples, the three implementations above can also have a sequential dependency. For example, please refer to Figure 7, which is a flowchart illustrating the sequential execution of different memory processing operations on the first memory pool according to this application. As shown in Figure 7, when the free memory of the first memory pool is lower than the memory low watermark, the operating system first performs memory migration on the first memory pool. If, after the operating system performs memory page migration, the free memory of the first memory pool is not lower than the memory high watermark, then the operating system stops performing memory processing operations on the first memory pool; if, after the operating system performs migration on all executable memory pages, the free memory of the first memory pool is still lower than the memory high watermark, then the operating system continues to perform memory reclamation on the first memory pool. If, after the operating system performs memory page reclamation, the free memory of the first memory pool is not lower than the memory high watermark, then the operating system stops performing memory processing operations on the first memory pool; if, after the operating system performs reclamation on all reclaimable memory pages, the free memory of the first memory pool is still lower than the memory high watermark, then the operating system continues to perform memory cleanup on the first memory pool until the free memory of the first memory pool is not lower than the memory high watermark. The memory low waterline and memory high waterline can be preset, and the memory low waterline is lower than the memory high waterline.

[0140] In addition, in the execution device, besides triggering memory reclamation or memory cleanup specifically for the first memory pool, the operating system can usually also perform memory reclamation or memory cleanup on the physical memory of the entire system (i.e., the first memory pool and the second memory pool) to ensure that there is enough free memory in the system.

[0141] However, since the first memory pool is a dedicated memory pool with limited usage, when the operating system calculates the free memory of the entire system to determine whether to trigger memory reclamation or memory cleanup for the entire system, it can perform a weighted summation of the free memory of different types of memory pools, thereby making the timing of triggering system memory reclamation or memory cleanup more appropriate.

[0142] For example, taking triggering system memory reclamation as an example, the operating system can first calculate the total amount of free physical memory. This physical memory includes a first memory pool and a second memory pool. The total free memory is obtained by performing a weighted sum of the free memory amounts in the first and second memory pools, with the weight corresponding to the free memory amount in the first memory pool being less than the weight corresponding to the free memory amount in the second memory pool. For example, the weight corresponding to the free memory amount in the first memory pool might be 0.5, 0.6, or 0.8, while the weight corresponding to the free memory amount in the second memory pool might be 1. In other words, the total amount of free physical memory is not obtained by directly adding the free memory amounts in each memory pool, but rather by assigning different weights to different memory pools and then performing a weighted sum. For example, assuming the free memory amount in the first memory pool is A and the free memory amount in the second memory pool is B, then the total amount of free physical memory C = 0.5 * A + B.

[0143] Furthermore, the operating system performs memory reclamation when the total amount of free physical memory meets the reclamation criteria. For example, the operating system performs memory reclamation when the total amount of free physical memory falls below the reclamation threshold.

[0144] In this scheme, when the system memory includes different types of memory pools, the operating system assigns a lower weight to memory pools with limited usage when calculating the total amount of free memory in the system memory. This can effectively characterize the actual amount of available memory in the system memory, thereby helping to accurately trigger the timing of system memory reclamation and ensuring the normal use of system memory.

[0145] Similarly, when the operating system calculates the free memory of the entire system to determine whether to trigger a system-wide memory scan, the operating system may assign different weights to the first memory pool and the second memory pool, and perform a weighted summation of the free memory amounts of the two memory pools to determine whether to trigger a system memory scan.

[0146] In addition, for the second memory pool, the operating system can also perform memory killing operations only on the memory in the second memory pool when the free memory in the second memory pool is insufficient, thereby realizing memory killing in the second memory pool.

[0147] The above describes how the operating system performs memory processing operations on the first memory pool when the free memory in the first memory pool is insufficient, thereby freeing up more free memory in the first memory pool to meet the demand. It can be understood that the purpose of freeing up more free memory in the first memory pool is actually to meet memory allocation needs, ensuring that memory allocation requests for the first memory pool can be responded to. Based on this, the following will describe how the operating system performs the memory allocation process to improve the rationality of memory allocation and ensure that requests for allocating dedicated memory in the first memory pool are responded to as much as possible.

[0148] For example, during the operation of the operating system, the operating system can obtain a memory allocation request, which is used to request the allocation of memory in a first memory pool. The memory allocation request can indicate the purpose of the requested memory, such as the targeted purpose or general purpose mentioned above.

[0149] At this point, the operating system determines whether to allocate memory from the first memory pool based on the intended use of the requested memory and the available memory in the first memory pool. In other words, the operating system can assign different priorities to memory allocation requests for different purposes. When the available memory in the first memory pool remains relatively constant, higher-priority memory allocation requests are more likely to be responded to, while lower-priority requests are less likely to be responded to.

[0150] Specifically, since the first memory pool is a dedicated memory pool specifically designed to provide memory for a specific purpose, and it is further reused to provide general-purpose memory in order to improve memory utilization, the operating system can treat memory allocation requests for different purposes within the first memory pool differently. This ensures that requests for memory for a specific purpose are prioritized. If a memory allocation request requests general-purpose memory from the first memory pool, the operating system may respond to the request only if there is sufficient free memory available in the first memory pool. Conversely, if a memory allocation request requests memory for a specific purpose from the first memory pool, the operating system may respond to the request even if there is limited free memory available in the first memory pool.

[0151] In summary, this solution determines whether to respond to a memory allocation request by combining the intended use of the memory requested in the memory allocation request with the available free memory in the first memory pool. When there is not much free memory left in the first memory pool, it can refuse to allocate memory for general purposes, thereby ensuring that the remaining free memory in the first memory pool is allocated to the target purpose first, and ensuring the effective allocation of dedicated memory.

[0152] Specifically, the operating system determines the first memory allocation line based on the intended use of the memory requested in the memory allocation request. For example, the operating system can pre-establish a mapping relationship between various uses of requested memory and memory allocation lines, so the operating system can determine the corresponding first memory allocation line based on the intended use of the memory requested in the memory allocation request.

[0153] If the free memory in the first memory pool is not lower than the first memory allocation threshold, the operating system determines to allocate memory from the first memory pool based on the memory allocation request. If the free memory in the first memory pool is lower than the first memory allocation threshold, the operating system determines not to allocate memory from the first memory pool.

[0154] In this context, the purpose of the memory allocation request can be either targeted or general-purpose. In the latter case, the memory allocation threshold for the targeted purpose is lower than that for the general-purpose purpose (meaning that the target-purpose memory can still be allocated even when free memory is low). The purpose of the memory allocation request can also be a more specific use within the targeted or general-purpose scope. For example, in the targeted purpose, it could be used as page table memory or kernel object memory; in the general-purpose scope, it could be used as anonymous pages or file pages. In short, for different types of purposes, the operating system can determine the corresponding memory allocation threshold and then decide whether to perform a memory allocation operation by comparing the memory allocation threshold with the free memory in the first memory pool.

[0155] Optionally, for different types of memory allocation requests, in order to better distinguish various memory allocation requests and avoid frequent memory migrations in the first memory pool, the operating system may determine the memory allocation line based on the migration cost or lifecycle stability of the memory requested by the memory allocation request.

[0156] For example, the memory allocation request obtained by the operating system is for general-purpose use. Furthermore, the first memory allocation line corresponding to this memory allocation request is determined based on the migration cost and / or lifecycle stability of the memory requested. The first memory allocation line is positively correlated with migration cost. That is, the higher the migration cost of the requested memory, the higher the first memory allocation line, indicating that the memory allocation request is more difficult to respond to; conversely, the lower the migration cost of the requested memory, the lower the first memory allocation line, indicating that the memory allocation request is easier to respond to. Furthermore, the first memory allocation line is negatively correlated with lifecycle stability. That is, the higher the lifecycle stability of the requested memory, the lower the first memory allocation line, indicating that the memory allocation request is easier to respond to.

[0157] Of course, when the memory requested in a memory allocation request is for a specific purpose, the first memory allocation threshold for that request can be determined based on the importance of the requested memory. That is, the more important the memory requested, the lower the first memory allocation threshold will be, to ensure that memory can be allocated more easily from the first memory pool.

[0158] For example, please refer to Figure 8, which is a schematic diagram of the memory allocation lines corresponding to different purposes when requesting memory pages according to this application. As shown in Figure 8, when the memory requested by the memory allocation request is for general purposes, the type of memory requested by the memory allocation request can specifically include memory pages that do not support migration (such as driver pages), anonymous pages, file pages, and protected memory pages (protected_lru pages). Among them, memory pages that do not support migration can be considered as memory pages with the highest migration cost (i.e., they cannot be migrated). Therefore, the memory allocation line corresponding to memory pages that do not support migration can be set to the same as the total memory of the first memory pool, so that the operating system will not allocate memory pages that do not support migration in the first memory pool. In addition, for file pages that have not been modified, they can be directly released during migration without following the standard migration process; while anonymous page migration must follow the standard migration process, that is, allocating a new memory page and changing all virtual memory mappings of the original memory page to map to the new memory page. Therefore, the migration cost of anonymous pages is higher than that of file pages, and the memory allocation line corresponding to anonymous pages can be set higher than that of file pages, so that file pages are easier to allocate than anonymous pages. Furthermore, protected memory pages refer to memory pages that will not trigger general reclamation. Therefore, the lifecycle of protected memory pages is very stable. A lower memory allocation threshold can be set for protected memory pages, thereby reducing the turnover frequency of memory pages and ensuring the stability of the reuse rate of the first memory pool.

[0159] When the memory requested in a memory allocation request is for a specific purpose, the type of memory requested can include kernel object pages and page table pages, among others. Page table pages are considered more important than kernel object pages; therefore, the memory allocation threshold for page table pages is lower than that for kernel object pages, meaning page table pages are more easily allocated than kernel object pages.

[0160] Furthermore, as shown in Figure 8, the memory allocation lines for various types of memory pages under the target purpose are all lower than those for various types of memory pages under the general purpose, indicating that the allocation priority of memory pages under the target purpose is higher than that of memory pages under the general purpose.

[0161] Please refer to Figure 9, which is a schematic diagram of a memory allocation process provided in this application. As shown in Figure 9, taking an execution device that includes a microkernel memory pool (i.e., the first memory pool mentioned above) and a general-purpose memory pool as an example, after the operating system obtains a memory allocation request, it first determines the purpose of the memory requested in the memory allocation request. If the memory requested in the memory allocation request is for microkernel purposes (such as requesting memory allocation for page tables or kernel objects), then the operating system believes that dedicated microkernel memory needs to be allocated for this memory allocation request. Therefore, the operating system specifies the allocation identifier in the microkernel memory pool and then allocates memory from the microkernel memory pool.

[0162] If the memory allocation request requests memory for microkernel purposes (such as requesting memory for page tables or kernel objects), the operating system assumes that dedicated microkernel memory needs to be allocated for the memory allocation request. Therefore, the operating system specifies the allocation identifier in the microkernel memory pool and then allocates memory from the microkernel memory pool.

[0163] If a memory allocation request requests general-purpose memory (such as requesting allocation of anonymous pages or file pages), the operating system assumes that memory can be allocated from either the microkernel memory pool or the general-purpose memory pool. Therefore, the operating system can specify an allocation identifier in the microkernel memory pool and allocate memory from there; or it can specify an allocation identifier in the general-purpose memory pool and allocate memory from there.

[0164] In general, if the memory allocation request requests memory for a specific purpose, the operating system can only allocate the corresponding memory from the dedicated memory pool (i.e., the microkernel memory pool); if the memory allocation request requests memory for a general purpose, the operating system can allocate the corresponding memory from either the dedicated memory pool or the general memory pool.

[0165] Please refer to Figure 10, which is a comparative schematic diagram of a memory allocation process provided in this application. As shown in Figure 10, during the process of the operating system allocating microkernel type memory (i.e., memory for the target purpose), the operating system first determines whether the free memory in the microkernel memory pool is not lower than the memory allocation threshold corresponding to that memory type. If the free memory in the microkernel memory pool is not lower than the memory allocation threshold corresponding to that memory type, then the operating system allocates the corresponding memory from the microkernel memory pool; if the free memory in the microkernel memory pool is lower than the memory allocation threshold corresponding to that memory type, it means that the operating system's attempt to allocate memory has failed, and the operating system can determine whether the number of allocation failures exceeds a certain number (e.g., 3 times). After the operating system attempts to allocate memory for the same memory allocation request more than a certain number of times, the operating system can consider the current memory allocation request to have increased priority. Therefore, the operating system temporarily adjusts the memory allocation threshold corresponding to the memory type requested by the memory allocation request and attempts to allocate memory again based on the new memory allocation threshold. After the operating system attempts to allocate memory for the same memory allocation request more than a specific number of times (e.g., 5 times), the operating system considers that memory allocation cannot be achieved at present, and then returns a memory allocation failure event.

[0166] During the allocation of general-purpose memory by the operating system, the operating system can determine whether the free memory in the microkernel memory pool is not lower than the memory allocation threshold corresponding to that memory type. If the free memory in the microkernel memory pool is lower than the memory allocation threshold, it means that the operating system cannot allocate that type of memory from the microkernel memory pool; that is, the operating system can only allocate the corresponding memory from the general-purpose memory pool. If the free memory in the microkernel memory pool is not lower than the memory allocation threshold, it means that the operating system can allocate that type of memory from either the microkernel memory pool or the general-purpose memory pool this time.

[0167] Please refer to Figure 11, which is a comparative diagram of a micro-core memory pool and a general-purpose memory pool provided in this application. As shown in Figure 11, based on the memory management method provided in this application, the micro-core memory pool can be reused, enabling it to provide general-purpose memory in addition to its dedicated purpose of providing memory for a specific target use. Furthermore, some data can be dynamically transferred between the micro-core memory pool and the general-purpose memory pool, thereby ensuring that the free memory in the micro-core memory pool is sufficient for use. Specifically, the memory in the micro-core memory pool can typically be used to store code segments, data segments, micro-core stacks, page tables, and kernel objects, i.e., the micro-core memory pool provides memory for a specific target use. However, the amount of memory used to store page tables and kernel objects is not fixed, so in some cases, there may be some free memory in the micro-core memory pool. In this case, the micro-core memory pool can provide some general-purpose memory, such as memory used as file pages or anonymous pages, thereby achieving partial memory reuse in the micro-core memory pool. The general-purpose memory pool is used to provide general-purpose memory, such as memory for file pages, anonymous pages, or driver pages. Furthermore, when the microkernel memory pool is insufficient for free memory, the operating system can migrate general-purpose memory (such as file pages and anonymous pages) from the microkernel memory pool to the general-purpose memory pool, thereby freeing up more free memory in the microkernel memory pool and ensuring that the microkernel memory pool can provide sufficient dedicated memory.

[0168] The methods provided in the embodiments of this application have been described in detail above. Next, the device for performing the above methods provided in the embodiments of this application will be described.

[0169] Please refer to Figure 12, which is a schematic diagram of the structure of a memory management device provided in this application. As shown in Figure 12, the memory management device includes: an acquisition module 1201, used to acquire the memory free status of a first memory pool, the first memory pool being a dedicated memory pool used to provide memory for a specific purpose, and capable of reusing free memory to provide general-purpose memory other than the specific purpose when available; and a processing module 1202, used to perform memory processing operations on the first memory pool to increase the free memory in the first memory pool when the memory free status meets preset conditions; wherein, the memory processing operations include at least one of memory migration, memory reclamation, and memory elimination, wherein memory migration involves migrating data in the general-purpose memory of the first memory pool to a second memory pool, the second memory pool being a general-purpose memory pool used only to provide general-purpose memory.

[0170] In one possible implementation, the preset conditions include memory migration conditions, the memory processing operation includes memory migration, and the processing module 1202 is specifically used to: when the memory migration conditions are met due to memory idleness, based on the memory management structure of the first memory pool, traverse the migrateable memory pages in the first memory pool, the purpose of which is general purpose; and migrate the data in the migrateable memory pages to the second memory pool.

[0171] In one possible implementation, the preset conditions include memory reclamation conditions, the memory processing operations include memory reclamation, and the processing module 1202 is specifically used to: determine the reclaimable memory pages in the first memory pool by traversing the LRU list when the memory is idle and the memory reclamation conditions are met; and perform memory reclamation on the reclaimable memory pages.

[0172] In one possible implementation, the preset conditions include memory killing conditions, the memory processing operation includes memory killing, and the processing module 1202 is specifically used to: determine at least one process occupying memory in the first memory pool when the memory is idle and the memory killing conditions are met; and perform a killing operation on at least one process.

[0173] In one possible implementation, the processing module 1202 is specifically used to: sort at least one process according to the killing priority to obtain a sorting result; kill at least one process in sequence based on the sorting result; wherein, when there are multiple processes with the same killing priority in the sorting result, the multiple processes are killed in sequence based on the memory usage of the processes in the first memory pool.

[0174] In one possible implementation, the acquisition module 1201 is further configured to acquire a memory allocation request, which is used to request the allocation of memory in the first memory pool; the processing module 1202 is further configured to determine whether to allocate memory in the first memory pool based on the purpose of the memory requested by the memory allocation request and the free memory in the first memory pool.

[0175] In one possible implementation, the processing module 1202 is specifically configured to: determine a first memory allocation line based on the purpose of the memory requested in the memory allocation request; if the free memory in the first memory pool is not lower than the first memory allocation line, determine to allocate memory in the first memory pool based on the memory allocation request; if the free memory in the first memory pool is lower than the first memory allocation line, determine not to allocate memory in the first memory pool.

[0176] In one possible implementation, the memory requested by the memory allocation request is for general purposes. The first memory allocation line is determined based on the migration cost and / or lifecycle stability of the memory requested by the memory allocation request. The level of the first memory allocation line is positively correlated with the migration cost and negatively correlated with the lifecycle stability.

[0177] In one possible implementation, the processing module 1202 is further configured to: calculate the total amount of free memory in the physical memory, the physical memory including a first memory pool and a second memory pool, the total amount of free memory being obtained by performing a weighted summation of the free memory amounts in the first memory pool and the second memory pool, the weight corresponding to the free memory amount in the first memory pool being less than the weight corresponding to the free memory amount in the second memory pool; and perform memory reclamation on the physical memory when the total amount of free memory meets the memory reclamation conditions.

[0178] In one possible implementation, the acquisition module 1201 acquires the memory free status of the first memory pool periodically.

[0179] In one possible implementation, the dedicated memory pool includes a microkernel memory pool or a CMA memory pool.

[0180] Please refer to Figure 13, which is a schematic diagram of the structure of an execution device provided in this application. As shown in Figure 13, the execution device 1300 can specifically be a smartphone, personal computer, laptop computer, tablet computer, smart car, or server, etc., and is not limited here. Specifically, the execution device 1300 includes: a receiver 1301, a transmitter 1302, a processor 1303, a local memory 1304, and a global memory 1305. The execution device 1300 can have multiple processors 1303, but only one processor is shown in Figure 13; the execution device 1300 can also have multiple local memories 1304, but only one local memory is shown in Figure 13. Furthermore, a local memory and one or more processors constitute a CC domain, thereby enabling the execution device 1300 to include multiple CC domains. The processor 1303 may include an application processor 13031 and a communication processor 13032. In some embodiments of this application, the receiver 1301, transmitter 1302, processor 1303, and memory 1304 can be connected via a bus or other means.

[0181] Memory 1304 may include read-only memory (ROM) and random access memory (RAM), and provides instructions and data to processor 1303. A portion of memory 1304 may also include non-volatile random access memory (NVRAM). Memory 1304 stores processor and operation instructions, executable modules, or data structures, or subsets thereof, or extended sets thereof, wherein the operation instructions may include various operation instructions for implementing various operations.

[0182] Processor 1303 controls the operation of the execution device. In specific applications, the various components of the execution device are coupled together through a bus system, which may include not only the data bus, but also power buses, control buses, and status signal buses. However, for clarity, all buses are referred to as the bus system in the diagram.

[0183] The methods disclosed in the embodiments of this application described above can be applied to processor 1303, or implemented by processor 1303. Processor 1303 can be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit in the hardware of processor 1303 or by instructions in the form of software. The processor 1303 described above can be a CPU, GPU, NPU, digital signal processor (DSP), microprocessor or microcontroller, and may further include application-specific integrated circuit (ASIC), field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0184] The processor 1303 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding 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. This storage medium is located in memory 1304. The processor 1303 reads information from memory 1304 and, in conjunction with its hardware, completes the steps of the above methods.

[0185] Receiver 1301 can be used to receive input digital or character information, and to generate signal inputs related to the settings and function control of the execution device. Transmitter 1302 can be used to output digital or character information through the first interface; transmitter 1302 can also be used to send instructions to the disk group through the first interface to modify the data in the disk group; transmitter 1302 may also include a display device such as a display screen.

[0186] The execution device provided in this application embodiment can specifically be a chip, which includes a processing unit and a communication unit. The processing unit can be, for example, a processor, and the communication unit can be, for example, an input / output interface, pins, or circuits. The processing unit can execute computer execution instructions stored in the storage unit to cause the chip in the execution device to execute the methods described in the above embodiments. Optionally, the storage unit can be an internal storage unit within the chip, such as a register or cache. Alternatively, the storage unit can be an external storage unit located within the wireless access device, such as a read-only memory or other types of static storage devices capable of storing static information and instructions, such as random access memory.

[0187] Referring to Figure 14, which is a schematic diagram of the structure of a computer-readable storage medium provided in this application. This application also provides a computer-readable storage medium in which, in some embodiments, the method disclosed in Figure 3 above can be implemented as computer program instructions encoded in a machine-readable format on a computer-readable storage medium or on other non-transitory media or articles of art.

[0188] Figure 14 schematically illustrates a conceptual partial view of an example computer-readable storage medium arranged according to at least one embodiment shown herein, the example computer-readable storage medium including a computer program for executing computer processes on a computing device.

[0189] In one embodiment, the computer-readable storage medium 1400 is provided using a signal bearer medium 1401. The signal bearer medium 1401 may include one or more program instructions 1402, which, when executed by one or more processors, can provide the functions or parts thereof described above with reference to FIG3.

[0190] In some examples, signal carrying medium 1401 may include computer-readable medium 1403, such as, but not limited to, hard disk drive, compact disc (CD), digital video disc (DVD), digital magnetic tape, memory, ROM or RAM, etc.

[0191] In some embodiments, the signal-bearing medium 1401 may include a computer-recordable medium 1404, such as, but not limited to, a memory, a read / write (R / W) CD, a R / W DVD, etc. In some embodiments, the signal-bearing medium 1401 may include a communication medium 1405, such as, but not limited to, digital and / or analog communication media (e.g., fiber optic cables, waveguides, wired communication links, wireless communication links, etc.). Therefore, for example, the signal-bearing medium 1401 may be transmitted by a wireless communication medium 1405 (e.g., a wireless communication medium conforming to the IEEE 802.X standard or other transmission protocols).

[0192] One or more program instructions 1402 may be, for example, computer-executable instructions or logical implementation instructions. In some examples, the computing device may be configured to provide various operations, functions, or actions in response to one or more program instructions 1402 conveyed to the computing device via a computer-readable medium 1403, a computer-recordable medium 1404, and / or a communication medium 1405.

[0193] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and 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 modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the accompanying drawings of the device embodiments provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.

[0194] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods of the various embodiments of this application.

[0195] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.

[0196] A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to the embodiments of this application is generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another. For example, computer instructions may be transferred from one website, computer, training device, or data center to another website, computer, training device, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).

Claims

1. A memory management method characterized by comprising: The method comprises: obtaining a memory idle condition of a first memory pool, the first memory pool being a dedicated memory pool, the first memory pool being used to provide memory for a target purpose, and the first memory pool being capable of being reused to provide memory for a general purpose other than the target purpose when having free memory; in a case where the memory idle condition meets a preset condition, performing a memory processing operation on the first memory pool to increase free memory in the first memory pool; wherein the memory processing operation comprises at least one of memory migration, memory reclamation, and memory killing, the memory migration being migration of data on memory belonging to the general purpose in the first memory pool to a second memory pool, the second memory pool being a general memory pool, the second memory pool being used only to provide memory for the general purpose.

2. The method of claim 1, wherein, The preset condition comprises a memory migration condition, the memory processing operation comprises memory migration, and the performing of the memory processing operation on the first memory pool comprises: in a case where the memory idle condition meets the memory migration condition, traversing a migratable memory page in the first memory pool based on a memory management structure of the first memory pool, the migratable memory page being of the general purpose; migrating data in the migratable memory page to the second memory pool.

3. The method according to claim 1 or 2, characterized in that, The preset condition comprises a memory reclamation condition, the memory processing operation comprises memory reclamation, and the performing of the memory processing operation on the first memory pool comprises: in a case where the memory idle condition meets the memory reclamation condition, determining a reclaimable memory page in the first memory pool by traversing a least recently used (LRU) linked list; performing memory reclamation on the reclaimable memory page.

4. The method according to any one of claims 1 to 3, characterized in that, The preset condition comprises a memory killing condition, the memory processing operation comprises memory killing, and the performing of the memory processing operation on the first memory pool comprises: in a case in which the memory idle condition meets the memory killing condition, determining at least one process occupying memory in the first memory pool; performing a killing operation on the at least one process.

5. The method of claim 4, wherein, The performing of the killing operation on the at least one process comprises: sorting the at least one process according to a killing priority to obtain a sorting result; killing the at least one process in sequence based on the sorting result; wherein, when there are multiple processes having the same killing priority in the sorting result, the multiple processes are killed in sequence based on memory occupation of the processes in the first memory pool.

6. The method according to any one of claims 1 to 5, characterized in that, The method further comprises: obtaining a memory allocation request, the memory allocation request being used to request allocation of memory in the first memory pool; determining, based on a purpose of memory requested to be allocated by the memory allocation request and free memory of the first memory pool, whether to allocate memory in the first memory pool based on the memory allocation request.

7. The method of claim 6, wherein, The determining, based on the purpose of memory requested to be allocated by the memory allocation request and the free memory of the first memory pool, whether to allocate memory in the first memory pool based on memory allocation request comprises: determining a first memory allocation line based on the purpose of memory requested to be allocated by the memory allocation request. determining, in a case where the free memory of the first memory pool is not lower than the first memory allocation line, to allocate memory in the first memory pool based on the memory allocation request; determining, in a case where the free memory of the first memory pool is lower than the first memory allocation line, not to allocate memory in the first memory pool.

8. The method of claim 7, wherein, The memory allocation request requests allocation of memory for the general purpose, and the first memory allocation line is determined based on a migration cost and / or a life cycle stability of the memory requested to be allocated by the memory allocation request. The first memory allocation line has a positive correlation with the migration cost, and the first memory allocation line has a negative correlation with the life cycle stability.

9. The method according to any one of claims 1 to 8, characterized in that, The method further includes: calculating a total free memory amount of physical memory including the first memory pool and the second memory pool, the total free memory amount being obtained by performing weighted summation on a free memory amount of the first memory pool and a free memory amount of the second memory pool, the free memory amount of the first memory pool corresponding to a weight smaller than a weight corresponding to the free memory amount of the second memory pool; performing memory recovery on the physical memory when the total free memory amount satisfies a memory recovery condition.

10. The method according to any one of claims 1 to 9, characterized in that, The acquisition of the memory free status of the first memory pool is triggered periodically.

11. The method according to any one of claims 1 to 10, characterized in that, The dedicated memory pool includes a microkernel memory pool or a continuous memory allocator (CMA) memory pool.

12. A memory management device, comprising: It includes: an acquisition module configured to acquire a memory free status of a first memory pool, the first memory pool being a dedicated memory pool, the first memory pool being used to provide memory for a target purpose, and the first memory pool being capable of being reused to provide memory for a general purpose other than the target purpose when having free memory; a processing module configured to perform a memory processing operation on the first memory pool to increase free memory in the first memory pool when the memory free status satisfies a preset condition; The memory processing operation includes at least one of memory migration, memory recovery, and memory killing. The memory migration is to migrate data on memory belonging to the general purpose in the first memory pool to a second memory pool, and the second memory pool is a general memory pool and is used to provide memory for the general purpose only.

13. The apparatus of claim 12, wherein, The preset condition includes a memory migration condition, and the memory processing operation includes memory migration. The processing module is specifically configured to: traverse migratable memory pages in the first memory pool based on a memory management structure of the first memory pool when the memory free status satisfies the memory migration condition, the migratable memory pages being for the general purpose; migrate data in the migratable memory pages to the second memory pool.

14. The apparatus of claim 12 or 13, wherein, The preset condition includes a memory recovery condition, and the memory processing operation includes memory recovery. The processing module is specifically configured to: determine recoverable memory pages in the first memory pool by traversing an LRU linked list when the memory free status satisfies the memory recovery condition; perform memory recovery on the recoverable memory pages.

15. The apparatus of any of claims 12-14, wherein, The preset condition includes a memory killing condition, and the memory processing operation includes memory killing. In a case where the memory idle condition satisfies the memory killing condition, determine at least one process occupying memory in the first memory pool; Perform a killing operation on the at least one process.

16. The apparatus of claim 15, wherein, The processing module is specifically configured to: Sort the at least one process according to a killing priority to obtain a sorting result; Kill the at least one process in sequence based on the sorting result; When there are multiple processes with the same killing priority in the sorting result, kill the multiple processes in sequence based on memory occupation of the processes in the first memory pool.

17. The apparatus of any one of claims 12-16, wherein: The obtaining module is further configured to obtain a memory allocation request, the memory allocation request being used to request allocation of memory in the first memory pool; The processing module is further configured to determine, based on a use of memory requested to be allocated by the memory allocation request and the idle memory of the first memory pool, whether to allocate memory in the first memory pool based on the memory allocation request.

18. The apparatus of claim 17, wherein, The processing module is specifically configured to: Determine a first memory allocation line based on the use of memory requested to be allocated by the memory allocation request; In a case where the idle memory of the first memory pool is not lower than the first memory allocation line, determine to allocate memory in the first memory pool based on the memory allocation request; In a case where the idle memory of the first memory pool is lower than the first memory allocation line, determine not to allocate memory in the first memory pool.

19. The apparatus of claim 18, wherein, The use of memory requested to be allocated by the memory allocation request is the general use, the first memory allocation line is determined based on a migration cost and / or a life cycle stability of the memory requested to be allocated by the memory allocation request, the level of the first memory allocation line has a positive correlation with the migration cost, and the level of the first memory allocation line has a negative correlation with the life cycle stability.

20. The apparatus of any of claims 12-19, wherein, The processing module is further configured to: Calculate a total idle memory amount of physical memory, the physical memory including the first memory pool and the second memory pool, the total idle memory amount being obtained by performing weighted summation on an idle memory amount of the first memory pool and an idle memory amount of the second memory pool, a weight corresponding to the idle memory amount of the first memory pool being smaller than a weight corresponding to the idle memory amount of the second memory pool; In a case where the total idle memory amount satisfies a memory recovery condition, perform memory recovery on the physical memory.

21. The apparatus of any of claims 12-20, wherein, The obtaining of the memory idle condition of the first memory pool is triggered periodically.

22. The apparatus of any of claims 12-21, wherein, The special-purpose memory pool includes a microkernel memory pool or a CMA memory pool.

23. A memory management device, comprising: An apparatus includes a memory storing code and a processor configured to execute the code, when the code is executed, the apparatus performs the method of any one of claims 1 to 11. An apparatus includes a memory storing code and a processor configured to execute the code, when the code is executed, the apparatus performs the method of any one of claims 1 to 11.

24. A computer storage medium, comprising, The computer storage medium stores instructions which, when executed by a computer, cause the computer to implement the method of any one of claims 1 to 11.

25. A computer program product, characterised in that, The computer program product stores instructions which, when executed by a computer, cause the computer to implement the method of any one of claims 1 to 11.