Memory allocation method and device, electronic equipment and nonvolatile storage medium
By reserving and assembling contiguous user-mode memory space for the application during memory initialization, the inefficiency caused by the application getting trapped in kernel mode when requesting memory is resolved, achieving efficient memory allocation that is suitable for real-time applications.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- INSPUR SUZHOU INTELLIGENT TECH CO LTD
- Filing Date
- 2024-11-30
- Publication Date
- 2026-04-24
AI Technical Summary
In existing technologies, applications need to enter kernel mode when requesting memory, resulting in low memory allocation efficiency and failing to meet the needs of applications with high real-time requirements.
During memory initialization, memory is reserved for the application according to the reserved memory configuration file and assembled into a contiguous user-mode memory space. The application requests memory directly from the pre-allocated memory during operation, without triggering the operating system's memory request step.
It effectively improves memory allocation efficiency, meets the needs of application scenarios with high real-time requirements, and enhances the usability of applications.
Smart Images

Figure CN119690862B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of storage technology, and in particular to a memory allocation method, apparatus, electronic device, and non-volatile storage medium. Background Technology
[0002] Memory allocation is the process by which the operating system allocates memory space for applications during runtime. Related technologies employ on-demand memory allocation to allocate memory to applications. This method, when an application requests memory, completes the memory request from the memory management subsystem within the operating system's kernel module through system calls, such as mmap (Memory-Mapped File).
[0003] Therefore, it is evident that the memory allocation process in these technologies still requires entering kernel mode to complete the allocation. This method impacts memory allocation efficiency and is unsuitable for applications with high real-time requirements. Consequently, resolving the issue of memory allocation in these technologies resulting in entry into kernel mode is a technical problem that needs to be addressed by those skilled in the art.
[0004] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this application, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0005] This invention provides a memory allocation method, apparatus, electronic device, and non-volatile storage medium. When an application requests memory, it does not trigger kernel-mode operations, effectively improving memory allocation efficiency and enhancing practicality.
[0006] To solve the above-mentioned technical problems, the present invention provides the following technical solution:
[0007] This invention provides a memory allocation method, comprising:
[0008] During memory initialization, corresponding application-specific memory is requested according to the reserved memory configuration file, and the application-specific memory is assembled into a contiguous memory space in a manner that the physical addresses are contiguous and belong to the same memory device.
[0009] In user space, based on the memory mapping information of the contiguous memory space mapped to user space triggered by a memory request, the contiguous memory space is assembled to generate a user space memory structure; when a memory call request sent by the target application during initialization is detected, the target application requests matching target memory from the user space memory structure and caches the target memory in the process space for use by the target application.
[0010] In a first exemplary embodiment, assembling the application-specific memory into a contiguous memory space based on physical address contiguity and belonging to the same memory device includes:
[0011] Obtain each free memory allocated from the operating system. Based on the physical address, memory space usage, memory device identification information, and non-consistent memory access of each free memory, assemble each free memory into non-consistent memory access, region, or page form according to the physical address contiguousness and belonging to the same memory device, so as to generate a contiguous memory space.
[0012] Upon receiving a memory request, each memory in the contiguous memory space is mapped to user space, and the physical address, memory space occupancy, and associated non-consistent memory access of each mapped memory are transmitted to user space as memory mapping information.
[0013] In a second exemplary implementation, the step of receiving a memory request, mapping each memory segment of the contiguous memory space to user space, and transmitting the physical address, memory space occupancy, and associated non-consistent memory access of each mapped memory segment to user space as memory mapping information includes:
[0014] Pre-configure user-space interfaces;
[0015] When a memory request is received through the user-space interface, each memory in the contiguous memory space is mapped to the user space, and the physical address, memory space occupied capacity, and non-consistent memory access of each mapped memory are transmitted to the user space through the user-space interface as memory mapping information.
[0016] In a third exemplary implementation, the step of requesting corresponding application-specific memory according to the reserved memory configuration file includes:
[0017] The system reads the reserved memory configuration file; the reserved memory configuration file includes at least reserved memory configuration information, operating system memory usage configuration information, and non-consistent memory access allocation information; the reserved memory configuration information includes the reserved memory percentage and the reserved memory space occupied capacity; the non-consistent memory access allocation information includes the pre-allocated memory percentage and the pre-allocated memory space occupied capacity on each non-consistent memory access; the operating system memory usage configuration information includes the operating system effective memory percentage, the operating system effective memory space occupied capacity, the operating system's effective memory percentage on each non-consistent memory access, and the operating system's effective memory space occupied capacity on each non-consistent memory access.
[0018] If the reserved memory configuration file includes the operating system's memory usage configuration information, the reserved memory configuration information, and the non-consistent memory access allocation information, then the corresponding application-specific memory is requested according to the operating system's memory usage configuration information; if the operating system's memory usage configuration information includes the operating system's effective memory percentage, the operating system's effective memory space percentage, the operating system's effective memory percentage on each non-consistent memory access, and the operating system's effective memory space occupancy on each non-consistent memory access, then the corresponding application-specific memory is requested according to the operating system's effective memory space occupancy on each non-consistent memory access.
[0019] If the reserved memory configuration file includes both the inconsistent memory access allocation information and the reserved memory configuration information, then the corresponding application-specific memory is requested according to the inconsistent memory access allocation information; if the inconsistent memory access allocation information includes both the pre-allocated memory percentage on each inconsistent memory access and the pre-allocated memory space occupied on each inconsistent memory access, then the corresponding application-specific memory is requested according to the pre-allocated memory space occupied on each inconsistent memory access.
[0020] If the reserved memory configuration file includes the reserved memory percentage and the reserved memory space usage capacity, then the corresponding application-specific memory is requested according to the reserved memory space usage capacity.
[0021] In a fourth exemplary implementation, the step of requesting matching target memory from the user-mode memory structure for the target application when a memory access request sent by the target application during initialization is detected includes:
[0022] Pre-configure memory allocation and reclamation interfaces;
[0023] When a target application is detected to send a memory call request through the memory allocation and reclamation interface, corresponding target memory is allocated to the target process executing the target application, and the target memory is allocated to the target process through the memory allocation and reclamation interface;
[0024] The memory usage of the target process is monitored through the memory allocation and reclamation interface, and an error is reported when the total memory usage of the target process exceeds the target memory.
[0025] In a fifth exemplary embodiment, after caching the target memory in the process space, the method further includes:
[0026] Obtain the memory allocation data of the target process executing the target application at the current moment, and the running status data of each thread contained in the target process;
[0027] Based on the memory allocation data, the running status data of each thread, and the usage of computing resources, determine whether the allocated memory of each thread needs to be migrated to its corresponding non-consistent memory access.
[0028] In the sixth exemplary implementation, determining whether the allocated memory of each thread needs to be migrated to its corresponding non-consistent memory access based on the memory allocation data, the running status data of each thread, and the computing resource usage method includes:
[0029] If the memory allocation data determines a first type of target thread that has memory allocated through a specified non-consistent memory access method, then the allocated memory of the first type of target thread will not be migrated.
[0030] Based on the running status data and computing resource usage of each thread, a second type of target thread using fixed computing resources is determined. If the allocated memory of the second type of thread does not match the corresponding dependent computing resources, the allocated memory of the second type of thread is migrated to the non-consistent memory access of the computing resources it depends on.
[0031] Another aspect of the present invention provides a memory allocation apparatus, comprising:
[0032] The memory allocation module is used to allocate corresponding application-specific memory according to the reserved memory configuration file during the memory initialization process, and assemble the application-specific memory into a contiguous memory space in a manner that the physical addresses are contiguous and belong to the same memory device;
[0033] The user-mode memory allocation module is used to assemble a user-mode memory structure in user mode based on the memory mapping information of the contiguous memory space mapped to user mode when a memory request is triggered. When a memory call request sent by a target application during initialization is detected, the module requests matching target memory from the user-mode memory structure for the target application and caches the target memory in the process space for use by the target application.
[0034] The present invention also provides an electronic device including a processor, the processor being configured to implement the steps of the memory allocation method as described in any of the preceding claims when executing a computer program stored in a memory.
[0035] Finally, the present invention also provides a non-volatile storage medium storing a computer program, which, when executed by a processor, implements the steps of the memory allocation method as described in any of the preceding claims.
[0036] The advantage of the technical solution provided by this invention is that, during the memory initialization process, the kernel-mode memory management subsystem reserves memory for the application in advance according to the reserved memory configuration file, and then assembles this reserved memory into a data structure that can be used in user mode. When the application requests memory during operation, it directly requests memory from the pre-allocated memory, without triggering the operating system's memory request-related steps. That is, it does not need to enter the memory mode operation, which effectively improves the memory allocation efficiency of the application, meets the needs of application scenarios with high real-time requirements, and has better practicality.
[0037] Furthermore, the present invention also provides corresponding implementation devices, electronic devices, and non-volatile storage media for the memory allocation method, further making the method more practical, and the devices, electronic devices, and non-volatile storage media have corresponding advantages.
[0038] The technical features mentioned above, those to be mentioned below, and those shown individually in the accompanying drawings can be arbitrarily combined with each other, provided that the combined technical features are not contradictory. All feasible combinations of features are the technical content explicitly described herein. Any one of the multiple sub-features contained in the same statement can be applied independently, without necessarily being applied together with other sub-features. It should be understood that the above general description and the following detailed description are merely exemplary and do not limit the invention. Attached Figure Description
[0039] To more clearly illustrate the technical solutions of the present invention or related technologies, the drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0040] Figure 1 A flowchart illustrating a memory allocation method provided by the present invention;
[0041] Figure 2 This is a schematic diagram of the memory initialization process provided by the present invention;
[0042] Figure 3 This is a schematic diagram of the memory adjustment judgment process provided by the present invention;
[0043] Figure 4 A schematic diagram of the framework of the memory allocation method provided by the present invention in an exemplary application scenario;
[0044] Figure 5 A schematic diagram of the framework of the application layer based on contiguous memory space provided by the present invention in an exemplary application scenario;
[0045] Figure 6 A schematic diagram illustrating the memory migration process of the application provided by the present invention in an exemplary application scenario;
[0046] Figure 7 A structural diagram of a specific embodiment of the memory allocation device provided by the present invention;
[0047] Figure 8 This is a structural diagram of a specific embodiment of the electronic device provided by the present invention. Detailed Implementation
[0048] To enable those skilled in the art to better understand the technical solutions of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. In this specification and the aforementioned drawings, the terms "first" and "second" are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. The term "exemplary" means "serving as an example, embodiment, or illustration." Any embodiment described herein as "exemplary" is not necessarily to be construed as superior to or better than other embodiments.
[0049] The operating system's memory management system is a kernel-level function. Applications request memory from the memory management subsystem within the operating system's kernel module using `brk` (a system call function) or `mmap`. The memory management subsystem allocates memory to the application according to a memory allocation strategy. For example, the memory allocation strategy might prioritize allocating memory from the CPU core within the same NUMA (Non-Uniform Memory Access) of the CPU (Central Processing Unit) executing the application process, or it might request memory from a slab (memory allocation mechanism) or buddy based on the requested size.
[0050] The memory management subsystem efficiently manages and allocates memory resources through mechanisms such as page frame allocators, virtual memory management, Slab / SLOB / SLUB allocators, huge page support, NUMA awareness, and cgroups (control groups). While the memory management subsystem provides comprehensive memory management and can adapt to various application scenarios, memory allocation strategies can be complex to configure and optimize in certain specific scenarios, such as high concurrency or allocation of a large number of small objects, resulting in low memory allocation efficiency. Because the memory management subsystem operates in kernel mode, application performance can be degraded due to switching between user mode and kernel mode, page faults, and other factors when applications request memory. To address this issue and improve memory allocation efficiency, related technologies utilize user-mode memory management tools, such as jemalloc and tcmalloc, for on-demand allocation. For example, jemalloc, through its thread-friendly design, multi-level page management, low fragmentation technology, and efficient memory reclamation mechanism, provides fast and stable memory allocation and management capabilities, making it suitable for applications that need to efficiently handle a large number of small objects and high concurrency scenarios. However, jemalloc has many configuration options, requiring tuning to achieve optimal performance, making the implementation process relatively complex and potentially introducing additional overhead. TCMalloc, through thread-local caching and paging mechanisms, can significantly reduce lock contention in multi-threaded environments, making it suitable for memory allocation in large-scale multi-threaded applications, and capable of efficiently managing and quickly allocating memory for small objects. However, TCMalloc is less efficient when handling large blocks of memory, lacks flexibility in optimization for certain applications, and its memory usage patterns can lead to high memory consumption.
[0051] Related technologies allocate memory to applications on demand using user-mode memory management tools. During application runtime, when a memory request is received, it can be allocated from the memory management subsystem via mmap or sbrk. However, these technologies still require triggering memory-mode operations, and therefore involve switching between user and kernel modes and page faults, resulting in low memory allocation efficiency.
[0052] In view of this, to solve the problem of low memory allocation efficiency caused by the need to enter kernel mode when requesting memory for applications, the present invention provides a method that reserves physical memory for applications during memory initialization and pre-allocates the memory used by applications when they start. During application execution, memory requests are directly made from the pre-allocated memory, without triggering the operating system's memory allocation steps. By pre-allocating system memory to the process space, this portion of memory is no longer managed by the system memory management subsystem but only by the memory management system itself, thereby improving the efficiency of application memory allocation. After introducing the technical solution of the present invention, various non-limiting embodiments of the present invention are described in detail below. To better illustrate the present invention, numerous specific details are given in the following detailed embodiments. Those skilled in the art should understand that the present invention can be implemented without these specific details. In other examples, methods, means, components, and circuits well known to those skilled in the art are not described in detail in order to highlight the main points of the present invention.
[0053] Please see first. Figure 1 , Figure 1 This is a flowchart illustrating a memory allocation method provided in this embodiment. This embodiment may include the following:
[0054] S101: During memory initialization, the corresponding application-specific memory is requested according to the reserved memory configuration file, and the application-specific memory is assembled into a contiguous memory space in a manner that the physical addresses are contiguous and belong to the same memory device.
[0055] The memory initialization process in this step is completed during the initialization process of the kernel memory management subsystem. The memory initialization process can be described as follows: Figure 2 As shown, the reserved memory configuration file is a file that records the memory that needs to be reserved for applications on the current server. It can be passed via the `grub` command line. Before memory allocation, memory is reserved according to this configuration file to prevent the operating system from allocating it to other processes. For ease of description, the memory reserved for applications is defined as application-specific memory, meaning memory exclusively used by the process corresponding to the user program. After requesting a specified amount of memory from the operating system based on the reserved memory configuration file, this memory is assembled in physical contiguous order for use by user-mode programs. For ease of description, the assembled memory is defined as a contiguous memory space, meaning that the physical addresses of the memory blocks in a contiguous memory space are consecutive and belong to the same memory device, such as a memory module.
[0056] S102: In user space, based on the memory mapping information of the contiguous memory space mapped to user space triggered by a memory allocation request, the contiguous memory space is assembled into a user-space memory structure. When a memory call request sent by the target application during initialization is detected, matching target memory is allocated from the user-space memory structure for the target application, and the target memory is cached in the process space for use by the target application.
[0057] After reserving memory for the application and assembling it into a memory space in the previous step, when user space requests memory, the assembled contiguous memory space is mapped from kernel space to user space. This mapping can be done, for example, using the `mmp` method. Then, based on the basic information of each mapped memory in the contiguous memory space—that is, the memory mapping information (including, but not limited to, the starting address, physical address, memory size, and NUMA)—the contiguous memory space is assembled into a memory structure usable by the application. For ease of description, this is defined as a user-space memory structure. When an application is detected to be requesting memory, to avoid distinction, the application sending the memory request is defined as the target application. Memory is allocated from the user-space memory structure according to the size of the requested memory. This allocated memory is defined as the target memory. The target memory can be the same size as or slightly larger than the requested memory. Finally, the target memory is cached in the process space corresponding to the process executing the target application. During the execution of the target application, the cached target memory in the process space is allocated to each thread executing the target application.
[0058] In the technical solution provided in this embodiment, the kernel-mode memory management subsystem reserves memory for the application in advance according to the reserved memory configuration file during memory initialization. Then, it assembles this reserved memory into a data structure that can be used in user mode. When the application requests memory during operation, it directly requests memory from the pre-allocated memory and no longer triggers the operating system's memory request steps. That is, it does not need to enter the memory mode operation, which effectively improves the memory allocation efficiency of the application, meets the needs of application scenarios with high real-time requirements, and has better practicality.
[0059] In the above embodiments, no limitation is made on how to assemble the application-specific program. Based on the above embodiments, the present invention also provides an exemplary implementation method, which may include the following:
[0060] The system acquires free memory allocated from the operating system. Based on the physical address, memory space usage, memory device identifier, and non-consistent memory access of each free memory, it assembles the free memory into non-consistent memory access, region, and page forms according to the physical address contiguousness and belonging to the same memory device to generate a contiguous memory space. Upon receiving a memory allocation request, the system maps each memory in the contiguous memory space to user space and transmits the physical address, memory space usage, and non-consistent memory access of each mapped memory as memory mapping information to user space.
[0061] In this embodiment, the memory device, such as a memory module, is identified by its serial number. Basic information about the currently acquired specified amount of memory is used to identify the memory. This basic information includes the physical address of each free memory segment, its memory space capacity, its associated memory device identification information, and its associated NUMA. This information is then assembled into NUMA, ZONE, and PAGE formats. Memory is requested from the kernel via a memory request. The kernel assembles these into contiguous memory segments and maps them to user space, saving the mapped addresses, sizes, and associated NUMA information. This information is then passed to the application when needed by user space, i.e., fed back to the application layer. User space allocates this memory to threads and manages the memory pool according to an initialization strategy. This initialization strategy includes the memory-thread allocation relationship, the memory's associated NUMA, and the correspondence between memory and CPU cores. Furthermore, for ease of monitoring and recording, the memory information currently allocated by the system can be printed out simultaneously, indicating which application allocated how much memory.
[0062] As an efficient memory allocation method, a user-mode interface can be pre-configured and provided to the user. When a memory request is received through the user-mode interface, each memory in the contiguous memory space is mapped to the user space. The physical address, memory space occupancy, and non-consistent memory access of each mapped memory are used as memory mapping information and transmitted to the user space through the user-mode interface.
[0063] As can be seen from the above, this embodiment assembles a data structure based on the basic memory information, and transmits the mapped data structure along with its memory information to the user space through a simple interface, which is beneficial to improving memory allocation efficiency.
[0064] In the above embodiments, no limitations are made on how to request application-specific memory from the operating system. Based on the above embodiments, the present invention also provides an exemplary implementation, which may include the following:
[0065] Read the reserved memory configuration file and request application-specific memory from the operating system according to the reserved memory configuration file and the priority policy of this embodiment.
[0066] The reserved memory configuration file may include at least reserved memory configuration information, operating system memory usage configuration information, and non-consistent memory access allocation information. The reserved memory configuration information may include at least one of the following: reserved memory percentage or reserved memory space capacity. The non-consistent memory access allocation information may include at least one of the following: pre-allocated memory percentage for each non-consistent memory access or pre-allocated memory space capacity for each non-consistent memory access. The operating system memory usage configuration information may include at least one of the following: operating system effective memory percentage, operating system effective memory space capacity, operating system effective memory percentage for each non-consistent memory access, or operating system effective memory space capacity for each non-consistent memory access. Users can configure the reserved memory configuration file in any one or more of the above methods according to actual requests. When multiple configuration methods exist in the reserved memory configuration file simultaneously, in order to improve the accuracy and efficiency of memory allocation, this embodiment sets corresponding priorities for the above configuration methods. The priority of the memory configuration to be used by the operating system is higher than the priority of the reserved memory configuration; the priority of the configuration method with a specified size is higher than the priority of the 100% configuration method; and the priority of the NUMA allocation method is higher than the priority of the overall reserved configuration method.
[0067] Based on the above priority configuration method, for example, when the reserved memory configuration file simultaneously includes the operating system's memory usage configuration information, the reserved memory configuration information, and the non-consistent memory access allocation information, then the corresponding application-specific memory is requested according to the operating system's memory usage configuration information; if the operating system's memory usage configuration information simultaneously includes the operating system's effective memory percentage, the operating system's effective memory space percentage capacity, the operating system's effective memory percentage on each non-consistent memory access, and the operating system's effective memory space occupancy capacity on each non-consistent memory access, then the corresponding application-specific memory is requested according to the operating system's effective memory space occupancy capacity on each non-consistent memory access. Dedicated memory for the application; if the reserved memory configuration file includes both the inconsistent memory access allocation information and the reserved memory configuration information, then the corresponding application-specific memory is requested according to the inconsistent memory access allocation information; if the inconsistent memory access allocation information includes both the pre-allocated memory percentage and the pre-allocated memory space capacity on each inconsistent memory access, then the corresponding application-specific memory is requested according to the pre-allocated memory space capacity on each inconsistent memory access; if the reserved memory configuration file includes both the reserved memory percentage and the reserved memory space capacity, then the corresponding application-specific memory is requested according to the reserved memory space capacity.
[0068] As can be seen from the above, this embodiment provides users with multiple memory allocation configuration methods, which are more flexible. Moreover, different priorities are set for different configuration methods, which effectively improves the accuracy and efficiency of memory allocation.
[0069] The above embodiments do not limit how memory is allocated to user programs. Based on the above embodiments, the present invention also provides an exemplary implementation method, which may include the following:
[0070] A memory allocation and reclamation interface is pre-configured; when a target application is detected to send a memory call request through the memory allocation and reclamation interface, corresponding target memory is allocated to the target process executing the target application, and the target memory is allocated to the target process through the memory allocation and reclamation interface; the memory usage of the target process is monitored through the memory allocation and reclamation interface, and an error is reported when the total memory usage of the target process exceeds the target memory.
[0071] In this embodiment, after the contiguous memory space is mapped to user space and assembled into a user-space memory structure for application use, when an application needs to access memory, it can pre-allocate a specified amount of memory from the user-space memory structure through the memory allocation and reclamation interface during the thread initialization phase of the process. For efficient use, the allocated target memory can be cached in the thread cache. To improve memory performance and avoid memory usage problems, this embodiment monitors the memory usage of the target application and reports errors immediately when they occur, effectively improving the memory access performance of the target application.
[0072] Related technologies require kernel-mode migration to transfer memory resources to the CPU when an application requests memory and undergoes NUMA migration due to load issues. Kernel-mode migration refers to the operating system migrating the application during runtime according to system load, with the memory management subsystem migrating the memory used by the application to the CPU memory where the application resides. To address the lack of memory migration capabilities in related technologies and the problem of passive memory migration via the memory management subsystem during NUMA migration, this invention dynamically adjusts the location of memory allocated and used by threads during application runtime to ensure that memory is always in the optimal position and that memory access performance is optimal. This embodiment provides an application-driven method for memory migration between NUMA environments. When a CPU migration occurs, the application decides whether the requested resources need to be migrated and actively migrates them, which may include the following:
[0073] Obtain the memory allocation data of the target process executing the target application at the current moment, and the running status data of each thread contained in the target process; based on the memory allocation data, the running status data of each thread, and the computing resource usage method, determine whether the allocated memory of each thread needs to be migrated to its corresponding non-consistent memory access.
[0074] The target process refers to the process executing the target application. Memory allocation data includes how much memory each thread of the target process is allocated, the NUMA to which the memory belongs, and the memory allocation method. The memory allocation method specifies whether it is allocated according to the memory used by the operating system, allocated according to NUMA, or allocated with a fixed size. Running status data refers to which CPU each thread is running on and which NUMA that CPU belongs to. Computational resource usage can be the allocation method of the CPU to which each thread belongs. For example... Figure 3As shown, this embodiment can initialize a monitoring thread in the background. This monitoring thread can obtain the current memory allocation and the running status information of each thread in the current process in real time or at regular intervals. It monitors whether the NUMA to which the memory currently allocated to the thread belongs is on the NUMA corresponding to the currently running CPU. If so, the current allocation is optimal. If not, it is on the currently running NUMA, and it needs to be determined whether it needs to be adjusted to the NUMA to which the thread belongs. If adjustment is needed, an asynchronous migration task is issued for migration. An exemplary determination method is as follows: Based on the memory allocation data, a first type of target thread is determined to have memory allocated through a specified non-consistent memory access method. The allocated memory of the first type of target thread is not migrated. Based on the running status data of each thread and the computing resource usage method, a second type of target thread using fixed computing resources is determined. If the allocated memory of the second type of thread does not match the corresponding dependent computing resources, the allocated memory of the second type of thread is migrated to the non-consistent memory access method where the computing resources it depends on reside. In other words, if the memory allocated to each thread is fixed, i.e., allocated through specified NUMA, then no adjustment is needed; however, if the memory allocated to each thread is based on the CPU to which the thread belongs or is automatically allocated, then adjustment is required. During adjustment, it is determined whether the current thread is running on a fixed CPU. If so, it is further checked whether the current memory-CPU mapping matches. If they do not match, the adjustment process is initiated to dynamically adjust the memory group based on the thread to which the memory belongs during runtime. For example, such as... Figure 4 As shown, the target process of the target application includes thread 1 and thread 2. Thread 1 exists in thread pool 1 and runs on CPU 1, while thread 2 exists in thread pool 2 and runs on CPU 6. The thread pool of thread 2 includes memory in NUMA 1 and memory in NUMA 0. Since thread 2 runs on CPU 6, it is necessary to determine whether the memory in thread pool 2 has been migrated from memory block 1 to memory block 2. If thread 2 is fixed to run on the NUMA where CPU 6 resides, then the contents of memory block 1 are migrated to memory block 2.
[0075] As can be seen from the above, this embodiment dynamically migrates the memory already allocated to a thread to the NUMA where the thread resides based on changes in the thread's running state. This is beneficial for improving memory allocation and program running efficiency in applications such as storage software. Moreover, dynamically adjusting the group to which the memory allocated to the application belongs during application execution can ensure application performance and guarantee that memory access during application execution is always in an optimal state.
[0076] The above embodiments do not limit how the mapped contiguous memory space is assembled into a user-usable memory structure. Based on the above embodiments, the present invention also provides a memory structure generation method, which may include the following:
[0077] Obtain the current application's runtime characteristics and task characteristics; select a matching memory structure assembly method based on the runtime characteristics and task characteristics.
[0078] In this embodiment, when a program is determined to have high real-time requirements based on its running characteristics and task characteristics, memory structure assembly can be performed based on NUMA. When the application program requires a large amount of contiguous memory, memory structure assembly can be performed based on BUDDY. When the application program frequently allocates and releases objects, memory structure assembly can be performed based on SLAB.
[0079] For example, when assembling memory structures based on NUMA, each NUMA node has its own `pg_data_t` structure to describe its memory layout. Each node is divided into multiple zones, and each zone is responsible for allocating different types of memory pages. The memory pages of each node are allocated through...
[0080] The `struct page` array manages memory, with each physical page mapped to a `struct page` object containing page status information such as allocation status and physical address. Memory structure assembly is based on the BUDDY approach, dividing memory into multiple levels of linked lists. Each list contains contiguous memory blocks of a specific size, ranging from 4KB to 4MB, with a total of 11 levels. That is, memory block sizes range from 2^0KB (4KB) to 2^10KB (4MB), with 11 levels and corresponding linked lists managing memory blocks of different sizes. When allocating memory, the system first searches for free blocks in the corresponding linked list. If no free block is found, it searches upwards in a larger linked list and breaks the large memory block into smaller blocks. When reclaiming memory, the system merges the memory blocks back into the corresponding linked lists. When memory structure assembly is based on the SLAB approach, memory is divided into multiple cache pools, each containing objects of a specific size. Objects in each cache pool are categorized into three states: free, partially used, and fully used. When an object needs to be allocated, it can be retrieved from the corresponding cache pool; when the object is released, it is returned to the cache pool for reuse.
[0081] As can be seen from the above, this embodiment provides different memory structures for users to use according to different application scenarios, which can not only improve effectiveness, but also improve memory allocation efficiency and memory management efficiency.
[0082] To make the embodiments of the present invention clearer to those skilled in the art, the present invention also provides an exemplary memory management system, which may include the following:
[0083] like Figure 5 As shown, the memory management system may include a thread-based application layer in user mode, an application layer based on contiguous memory space, and a memory allocation driver layer in kernel mode. Among them, such as... Figure 6 As shown, the application layer based on contiguous memory space may include a memory allocation and reclamation interface, a user-mode memory structure, a memory allocation module, and a memory migration module.
[0084] The memory allocation driver layer is used during memory initialization to request a specified amount of free memory from the operating system. It identifies the basic information of the acquired memory and assembles this information into NUMA, ZONE, and PAGE formats according to physical continuity, resulting in a contiguous memory space for user-mode programs. The memory allocation driver layer provides a user-mode interface and prints out the allocated memory information.
[0085] In this process, the thread-based application layer requests memory from the kernel through a user-mode interface. It then maps the contiguous memory space requested from the kernel to user mode, assembling the memory according to concepts such as NUMA, PAGE, BUDDY, and SLAB into a user-mode memory structure usable by the application. Finally, it allocates this memory to threads and manages the memory pool according to initialization strategies. Figure 6 As shown, it provides a memory allocation and reclamation interface for thread-based application layers. Through a memory migration module, it dynamically migrates memory already allocated to a thread to its respective NUMA based on changes in the thread's running state. The thread-based application layer is used to allocate and release memory for application threads, and when memory migration is needed, it migrates the thread's allocated memory to the CPU's NUMA.
[0086] As can be seen from the above, the memory management system provided in this embodiment uses a memory pre-allocation method to request the memory required by the application in the application space in advance. During the application's operation, it can migrate the memory to the NUMA of the running CPU, effectively improving the application's performance and ensuring that the application's memory access is always in the optimal state during the application's operation.
[0087] It should be noted that there is no strict order of execution between the steps in this invention. As long as they conform to the logical order, these steps can be executed simultaneously or in a certain preset order. Figures 1-3 This is just an illustrative example and does not mean that this is the only possible execution order.
[0088] This invention also provides a corresponding apparatus for the memory allocation method, further enhancing the practicality of the method. The apparatus can be described from both a functional module perspective and a hardware perspective. The memory allocation apparatus provided by this invention is described below. This apparatus is used to implement the memory allocation method provided by this invention. In this embodiment, the memory allocation apparatus may include or be divided into one or more program modules. These one or more program modules are stored in a storage medium and executed by one or more processors to complete the memory allocation method disclosed in Embodiment 1. The program module referred to in this embodiment refers to a series of computer program instruction segments capable of performing a specific function, which is more suitable than the program itself for describing the execution process of the memory allocation apparatus in the storage medium. The following description will specifically introduce the functions of each program module in this embodiment. The memory allocation apparatus described below and the memory allocation method described above can be referred to in correspondence.
[0089] From the perspective of functional modules, see Figure 7 , Figure 7 This is a structural diagram of the memory allocation device provided in this embodiment under one specific implementation. The device may include:
[0090] The memory allocation module 701 is used to allocate corresponding application-specific memory according to the reserved memory configuration file during the memory initialization process, and assemble the application-specific memory into a contiguous memory space in a manner that the physical addresses are contiguous and belong to the same memory device.
[0091] User-mode memory allocation module 702 is used to assemble a user-mode memory structure in user mode based on memory mapping information of a contiguous memory space mapped to user mode under the trigger of a memory request; when a memory call request sent by a target application during initialization is detected, the module requests matching target memory from the user-mode memory structure for the target application and caches the target memory in the process space for use by the target application.
[0092] For example, in some embodiments of this example, the memory allocation module 701 described above can also be used for:
[0093] The system acquires free memory allocated from the operating system. Based on the physical address, memory space usage, memory device identifier, and non-consistent memory access of each free memory, it assembles the free memory into non-consistent memory access, region, and page forms according to the physical address contiguousness and belonging to the same memory device to generate a contiguous memory space. Upon receiving a memory allocation request, the system maps each memory in the contiguous memory space to user space and transmits the physical address, memory space usage, and non-consistent memory access of each mapped memory as memory mapping information to user space.
[0094] As an exemplary implementation of the above embodiments, the memory allocation module 701 can also be used for:
[0095] A user-space interface is pre-configured; when a memory request is received through the user-space interface, each memory in the contiguous memory space is mapped to the user space, and the physical address, memory space occupancy capacity, and non-consistent memory access of each mapped memory are transmitted to the user space through the user-space interface as memory mapping information.
[0096] For example, in some other embodiments of this example, the memory allocation module 701 described above can also be used for:
[0097] The system reads the reserved memory configuration file; the reserved memory configuration file includes at least reserved memory configuration information, operating system memory usage configuration information, and non-consistent memory access allocation information; the reserved memory configuration information includes the reserved memory percentage and the reserved memory space occupied capacity; the non-consistent memory access allocation information includes the pre-allocated memory percentage and the pre-allocated memory space occupied capacity on each non-consistent memory access; the operating system memory usage configuration information includes the operating system effective memory percentage, the operating system effective memory space occupied capacity, the operating system's effective memory percentage on each non-consistent memory access, and the operating system's effective memory space occupied capacity on each non-consistent memory access.
[0098] If the reserved memory configuration file includes the operating system's memory usage configuration information, the reserved memory configuration information, and the non-consistent memory access allocation information, then the corresponding application-specific memory is requested according to the operating system's memory usage configuration information; if the operating system's memory usage configuration information includes the operating system's effective memory percentage, the operating system's effective memory space percentage, the operating system's effective memory percentage on each non-consistent memory access, and the operating system's effective memory space occupancy on each non-consistent memory access, then the corresponding application-specific memory is requested according to the operating system's effective memory space occupancy on each non-consistent memory access.
[0099] If the reserved memory configuration file includes both the inconsistent memory access allocation information and the reserved memory configuration information, then the corresponding application-specific memory is requested according to the inconsistent memory access allocation information; if the inconsistent memory access allocation information includes both the pre-allocated memory percentage on each inconsistent memory access and the pre-allocated memory space occupied on each inconsistent memory access, then the corresponding application-specific memory is requested according to the pre-allocated memory space occupied on each inconsistent memory access.
[0100] If the reserved memory configuration file includes the reserved memory percentage and the reserved memory space usage capacity, then the corresponding application-specific memory is requested according to the reserved memory space usage capacity.
[0101] For example, in some other embodiments of this example, the user-mode memory allocation module 702 described above can also be used for:
[0102] A memory allocation and reclamation interface is pre-configured; when a target application is detected to send a memory call request through the memory allocation and reclamation interface, corresponding target memory is allocated to the target process executing the target application, and the target memory is allocated to the target process through the memory allocation and reclamation interface; the memory usage of the target process is monitored through the memory allocation and reclamation interface, and an error is reported when the total memory usage of the target process exceeds the target memory.
[0103] For example, in some other embodiments of this example, the above-described apparatus may further include a memory adjustment and migration module, which can be used for:
[0104] Obtain the memory allocation data of the target process executing the target application at the current moment, and the running status data of each thread contained in the target process;
[0105] Based on the memory allocation data, the running status data of each thread, and the usage of computing resources, determine whether the allocated memory of each thread needs to be migrated to its corresponding non-consistent memory access.
[0106] As an exemplary implementation of the above embodiments, the memory adjustment and migration module can also be used for:
[0107] If a first type of target thread is determined based on the memory allocation data and memory is allocated through a specified non-consistent memory access method, then the allocated memory of the first type of target thread will not be migrated. If a second type of target thread is determined based on the running status data and computing resource usage method of each thread, and the allocated memory of the second type of thread does not match the corresponding dependent computing resource, then the allocated memory of the second type of thread will be migrated to the non-consistent memory access method where the computing resource it depends on is located.
[0108] The memory allocation device mentioned above is described from the perspective of a functional module. Furthermore, the present invention also provides an electronic device, which is described from the perspective of hardware. Figure 8 This is a schematic diagram of the structure of an electronic device provided in one embodiment of the present invention. For example... Figure 8As shown, the electronic device includes a memory 80 for storing a computer program; and a processor 81 for implementing the steps of the memory allocation method as described in any of the above embodiments when executing the computer program.
[0109] The processor 81 may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor 81 may also be a controller, microcontroller, microprocessor, or other data processing chip. The processor 81 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 81 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 81 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor 81 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.
[0110] The memory 80 may include one or more computer non-volatile storage media, which may be non-transitory. The memory 80 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the memory 80 may be an internal storage unit of an electronic device, such as a server hard drive. In other embodiments, the memory 80 may be an external storage device of an electronic device, such as a plug-in hard drive on a server, a Smart Media Card (SMC), a Secure Digital (SD) card, or a Flash Card. Furthermore, the memory 80 may include both internal and external storage units of the electronic device. The memory 80 can be used not only to store application software and various types of data installed on the electronic device, such as code in the process of executing the memory allocation method, but also to temporarily store data that has been output or will be output. In this embodiment, the memory 80 is used to store at least the following computer program 801, which, after being loaded and executed by the processor 81, can implement the relevant steps of the memory allocation method disclosed in any of the foregoing embodiments. In addition, the resources stored in memory 80 may also include operating system 802 and data 803, and the storage method may be temporary storage or permanent storage. Operating system 802 may include Windows, Unix, Linux, etc. Data 803 may include, but is not limited to, data corresponding to memory allocation results.
[0111] In some embodiments, the aforementioned electronic device may further include a display screen 82, an input / output interface 83, a communication interface 84 (or network interface), a power supply 85, and a communication bus 86. The display screen 82 and input / output interface 83, such as a keyboard, are user interfaces. Exemplary user interfaces may also include standard wired interfaces, wireless interfaces, etc. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen, etc. The display may also be appropriately referred to as a display screen or display unit, used to display information processed in the electronic device and to display a visual user interface. The communication interface 84 may exemplary include wired and / or wireless interfaces, such as a Wi-Fi interface, a Bluetooth interface, etc., typically used to establish communication connections between the electronic device and other electronic devices. The communication bus 86 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. This bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0112] Those skilled in the art will understand that Figure 8 The structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, such as sensors 87 that perform various functions.
[0113] It is understood that if the memory allocation method in the above embodiments is implemented as a software functional unit and sold or used as an independent product, it can be stored in a non-volatile storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the related technology, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and executes all or part of the steps of the methods in the various embodiments of the present invention. The aforementioned storage medium includes, but is not limited to, various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), electrically erasable programmable ROM, registers, hard disks, multimedia cards, card-type memories (e.g., SD or DX memories), magnetic memories, removable disks, CD-ROMs, magnetic disks, or optical disks. Based on this, the present invention also provides a non-volatile storage medium storing a computer program, which, when executed by a processor, performs the steps of the memory allocation method as described in any of the above embodiments.
[0114] It is understood that if the memory allocation method in the above embodiments is implemented as a software functional unit and sold or used as an independent product, the computer software product may not need to be stored in a physical storage medium. For example, it can be directly transmitted to a computer or other device with information processing capabilities via a wired or wireless network to execute all or part of the steps of the methods in the various embodiments of the present invention. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the related technology, or all or part of the technical solution, can be embodied in the form of a software product. Based on this, the present invention also provides a computer program product storing a computer program, which, when executed by a processor, performs the steps of the memory allocation method as described in any of the above embodiments.
[0115] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. The hardware disclosed in the embodiments, including devices, electronic devices, and non-volatile storage media, is described simply because it corresponds to the methods disclosed in the embodiments; relevant details can be found in the method section.
[0116] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0117] The present invention has provided a detailed description of a memory allocation method, apparatus, electronic device, and non-volatile storage medium. Specific examples have been used to illustrate the principles and implementation methods of the invention. The descriptions of these embodiments are merely illustrative of the method and its core ideas. It should be noted that, based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention. Several improvements and modifications can be made to the present invention without departing from its principles, and these improvements and modifications also fall within the scope of protection of the present invention.
Claims
1. A memory allocation method, characterized in that, include: During memory initialization, corresponding application-specific memory is requested according to the reserved memory configuration file, and the application-specific memory is assembled into a contiguous memory space in a manner that the physical addresses are contiguous and belong to the same memory device. In user space, the contiguous memory space is assembled into a user space memory structure based on the memory mapping information of the contiguous memory space mapped to user space when triggered by a memory allocation request. When a memory access request sent by the target application during initialization is detected, the system requests matching target memory from the user-mode memory structure for the target application and caches the target memory in the process space for use by the target application. The application-dedicated memory allocation process includes: reading a reserved memory configuration file; the reserved memory configuration file includes at least one of the following: reserved memory configuration information, operating system memory usage configuration information, and non-consistent memory access allocation information; the reserved memory configuration information includes the reserved memory percentage and the reserved memory space occupied capacity; the non-consistent memory access allocation information includes the pre-allocated memory percentage and the pre-allocated memory space occupied capacity for each non-consistent memory access; the operating system memory usage configuration information includes the operating system's effective memory percentage, the operating system's effective memory space occupied capacity, the operating system's effective memory percentage for each non-consistent memory access, and the operating system's effective memory space occupied capacity for each non-consistent memory access. If the reserved memory configuration file includes operating system memory usage configuration information, reserved memory configuration information, and inconsistent memory access allocation information, then the corresponding application-specific memory is requested according to the operating system memory usage configuration information; if the operating system memory usage configuration information includes the operating system's effective memory percentage, the operating system's effective memory space percentage, the operating system's effective memory percentage on each inconsistent memory access, and the operating system's effective memory space usage on each inconsistent memory access, then the corresponding application-specific memory is requested according to the operating system's effective memory space usage on each inconsistent memory access. If the reserved memory configuration file includes both inconsistent memory access allocation information and reserved memory configuration information, then the corresponding application-specific memory is requested according to the inconsistent memory access allocation information; if the inconsistent memory access allocation information includes both the pre-allocated memory percentage on each inconsistent memory access and the pre-allocated memory space occupied on each inconsistent memory access, then the corresponding application-specific memory is requested according to the pre-allocated memory space occupied on each inconsistent memory access. When the reserved memory configuration file includes the reserved memory percentage and the reserved memory space usage capacity, the corresponding application-specific memory will be requested according to the reserved memory space usage capacity.
2. The memory allocation method according to claim 1, characterized in that, The step of assembling the application-specific memory into a contiguous memory space based on physical address contiguousness and belonging to the same memory device includes: Obtain each free memory allocated from the operating system. Based on the physical address, memory space usage, memory device identification information, and non-consistent memory access of each free memory, assemble each free memory into non-consistent memory access, region, or page form according to the physical address contiguousness and belonging to the same memory device, so as to generate a contiguous memory space. Upon receiving a memory request, each memory in the contiguous memory space is mapped to user space, and the physical address, memory space occupancy, and associated non-consistent memory access of each mapped memory are transmitted to user space as memory mapping information.
3. The memory allocation method according to claim 2, characterized in that, Upon receiving a memory request, the step of mapping each memory segment of the contiguous memory space to user space, and transmitting the physical address, memory space occupancy, and associated non-consistent memory access of each mapped memory segment to user space as memory mapping information, includes: Pre-configure user-space interfaces; When a memory request is received through the user-space interface, each memory in the contiguous memory space is mapped to the user space, and the physical address, memory space occupied capacity, and non-consistent memory access of each mapped memory are transmitted to the user space through the user-space interface as memory mapping information.
4. The memory allocation method according to claim 1, characterized in that, The step of requesting matching target memory from the user-mode memory structure for the target application when a memory call request sent by the target application during initialization is detected includes: Pre-configure memory allocation and reclamation interfaces; When a target application is detected to send a memory call request through the memory allocation and reclamation interface, corresponding target memory is allocated to the target process executing the target application, and the target memory is allocated to the target process through the memory allocation and reclamation interface; The memory usage of the target process is monitored through the memory allocation and reclamation interface, and an error is reported when the total memory usage of the target process exceeds the target memory.
5. The memory allocation method according to any one of claims 1 to 4, characterized in that, After caching the target memory in the process space, the method further includes: Obtain the memory allocation data of the target process executing the target application at the current moment, and the running status data of each thread contained in the target process; Based on the memory allocation data, the running status data of each thread, and the usage of computing resources, determine whether the allocated memory of each thread needs to be migrated to its corresponding non-consistent memory access.
6. The memory allocation method according to claim 5, characterized in that, The step of determining whether the allocated memory of each thread needs to be migrated to its corresponding non-consistent memory access based on the memory allocation data, the running status data of each thread, and the computing resource usage method includes: If the memory allocation data determines a first type of target thread that has memory allocated through a specified non-consistent memory access method, then the allocated memory of the first type of target thread will not be migrated. Based on the running status data and computing resource usage of each thread, a second type of target thread using fixed computing resources is determined. If the allocated memory of the second type of target thread does not match the corresponding dependent computing resources, the allocated memory of the second type of target thread is migrated to the non-consistent memory access of the computing resources it depends on.
7. A memory allocation device, characterized in that, include: The memory allocation module is used to allocate corresponding application-specific memory according to the reserved memory configuration file during the memory initialization process, and assemble the application-specific memory into a contiguous memory space in a manner that the physical addresses are contiguous and belong to the same memory device; The user-mode memory allocation module is used to assemble the contiguous memory space into a user-mode memory structure in user mode according to the memory mapping information of the contiguous memory space mapped to user mode under the trigger of memory request; When a memory access request sent by the target application during initialization is detected, the system requests matching target memory from the user-mode memory structure for the target application and caches the target memory in the process space for use by the target application. The memory allocation module is further configured to: read a reserved memory configuration file; the reserved memory configuration file includes at least one of the following: reserved memory configuration information, operating system memory usage configuration information, and non-consistent memory access allocation information; the reserved memory configuration information includes the reserved memory percentage and the reserved memory space occupied capacity; the non-consistent memory access allocation information includes the pre-allocated memory percentage and the pre-allocated memory space occupied capacity on each non-consistent memory access; the operating system memory usage configuration information includes the operating system effective memory percentage, the operating system effective memory space occupied capacity, the operating system's effective memory percentage on each non-consistent memory access, and the operating system's effective memory space occupied capacity on each non-consistent memory access; If the reserved memory configuration file includes operating system memory usage configuration information, reserved memory configuration information, and inconsistent memory access allocation information, then the corresponding application-specific memory is requested according to the operating system memory usage configuration information; if the operating system memory usage configuration information includes the operating system's effective memory percentage, the operating system's effective memory space percentage, the operating system's effective memory percentage on each inconsistent memory access, and the operating system's effective memory space usage on each inconsistent memory access, then the corresponding application-specific memory is requested according to the operating system's effective memory space usage on each inconsistent memory access. If the reserved memory configuration file includes both inconsistent memory access allocation information and reserved memory configuration information, then the corresponding application-specific memory is requested according to the inconsistent memory access allocation information; if the inconsistent memory access allocation information includes both the pre-allocated memory percentage on each inconsistent memory access and the pre-allocated memory space occupied on each inconsistent memory access, then the corresponding application-specific memory is requested according to the pre-allocated memory space occupied on each inconsistent memory access. When the reserved memory configuration file includes the reserved memory percentage and the reserved memory space usage capacity, the corresponding application-specific memory will be requested according to the reserved memory space usage capacity.
8. An electronic device, characterized in that, It includes a processor and a memory, wherein the processor is configured to implement the steps of the memory allocation method as described in any one of claims 1 to 6 when executing a computer program stored in the memory.
9. A non-volatile storage medium, characterized in that, The non-volatile storage medium stores a computer program, which, when executed by a processor, implements the steps of the memory allocation method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Memory reservation method and apparatus
CN106708752A
Memory allocation method, apparatus and system
WO2022237624A1