Memory allocation method and device, electronic equipment and nonvolatile storage medium
By reserving and assembling continuous memory space for the application during memory initialization, the problem of memory application needs to fall into kernel state in the existing technology is solved, which improves memory allocation efficiency and meets the application needs with high real-time performance.
Patent Information
- Application Number
- CN202411755498.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-30
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2044-11-30
AI Technical Summary
When applying for memory for applications, the prior art needs to fall into the kernel state, resulting in low memory allocation efficiency and inability to meet the needs of high real-time application scenarios.
By reserving physical memory for the application in advance according to the reserved memory configuration file during memory initialization, and assembling it into continuous memory space, the application directly applies from the preallocated memory during operation, and no longer triggers the memory application step of the operating system.
It effectively improves the memory allocation efficiency of the application, avoids the performance reduction caused by kernel-state switching, and meets the application scenario requirements with high real-time requirements.
Smart Images

Figure CN119690862A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of storage technology, and in particular to a memory allocation method, device, electronic equipment and non-volatile storage medium. Background Art
[0002] Memory allocation is the process of allocating memory space to an application when the operating system is running. The related technology uses memory on-demand allocation to allocate memory to an application. When an application needs to apply for memory, this method completes the memory application from the memory management subsystem in the kernel module of the operating system through a system call method, such as mmap (Memory-Mapped File).
[0003] It can be seen that the memory application process of the related technology still falls into the kernel state to complete the application. This method will affect the efficiency of memory allocation and is not suitable for some application scenarios with high real-time requirements. In view of this, solving the problem of falling into the kernel state when applying for memory in the related technology is a technical problem that technicians in this field need to solve.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present application, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0005] The present invention provides a memory allocation method, device, electronic device and non-volatile storage medium. When an application applies for memory, kernel state operation is not triggered, memory allocation efficiency is effectively improved, and practicality is better.
[0006] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0007] The present invention provides a memory allocation method, comprising:
[0008] During the memory initialization process, the corresponding application-specific memory is applied for according to the reserved memory configuration file, and the application-specific memory is assembled into a continuous memory space in a manner that the physical addresses are continuous and belong to the same memory device;
[0009] In user mode, according to the memory mapping information of the continuous memory space mapped to the user mode triggered by the memory application request, the continuous memory space is assembled to generate a user mode memory structure; when a memory call request sent by the target application during the initialization process is detected, a matching target memory is requested from the user mode memory structure for the target application, and the target memory is cached to the process space for use by the target application.
[0010] In a first exemplary implementation, assembling the application-specific memory into a continuous memory space in a manner that the application-specific memory is continuous in physical addresses and belongs to the same memory device includes:
[0011] Obtain each free memory requested from the operating system, and assemble each free memory into non-consistent memory access, region, and page forms according to the physical address, memory space occupied capacity, memory device identification information, and non-consistent memory access of each free memory, in a manner that the physical address is continuous and belongs to the same memory device, so as to generate a continuous memory space;
[0012] Upon receiving a memory application request, each memory of the continuous memory space is mapped to the user state, and the physical address of each mapped memory, the memory space occupied capacity and the non-consistent memory access to which it belongs are transmitted to the user state as memory mapping information.
[0013] In a second exemplary implementation, upon receiving a memory application request, mapping each memory of the continuous memory space to a user state, and passing the physical address of each mapped memory, the memory space occupied capacity, and the non-consistent memory access to which it belongs as memory mapping information to the user state, including:
[0014] Pre-configure user-mode interfaces;
[0015] When a memory application request is received through the user state interface, each memory of the continuous memory space is mapped to the user state, and the physical address of each mapped memory, the memory space occupied capacity and the non-consistent memory access to which it belongs are used as memory mapping information and transmitted to the user state through the user state interface.
[0016] In a third exemplary implementation, applying for corresponding application-specific memory according to the reserved memory configuration file includes:
[0017] Read a reserved memory configuration file; the reserved memory configuration file includes at least reserved memory configuration information, operating system memory configuration information, and non-consistent memory access allocation information; the reserved memory configuration information includes a reserved memory ratio and a reserved memory space occupied capacity; the non-consistent memory access allocation information includes a pre-allocated memory ratio for each non-consistent memory access and a pre-allocated memory space occupied capacity for each non-consistent memory access; the operating system memory configuration information includes an operating system effective memory ratio, an operating system effective memory space occupied capacity, an operating system effective memory ratio for each non-consistent memory access, and an operating system effective memory space occupied capacity for each non-consistent memory access;
[0018] When the reserved memory configuration file includes the memory configuration information used by the operating system, the reserved memory configuration information and the non-consistent memory access allocation information at the same time, the corresponding application-specific memory is applied for according to the memory configuration information used by the operating system; if the memory configuration information used by the operating system includes the operating system's effective memory ratio, the operating system's effective memory space ratio, the operating system's effective memory ratio on each non-consistent memory access, and the operating system's effective memory space occupancy capacity on each non-consistent memory access, the corresponding application-specific memory is applied for according to the operating system's effective memory space occupancy capacity on each non-consistent memory access;
[0019] When the reserved memory configuration file includes both the non-consistent memory access allocation information and the reserved memory configuration information, the corresponding application-specific memory is applied for according to the non-consistent memory access allocation information; if the non-consistent memory access allocation information includes both the pre-allocated memory ratio of each non-consistent memory access and the occupied capacity of the pre-allocated memory space of each non-consistent memory access, the corresponding application-specific memory is applied for according to the occupied capacity of the pre-allocated memory space of each non-consistent memory access;
[0020] When the reserved memory configuration file includes the reserved memory percentage and the reserved memory space occupied capacity, the corresponding application-specific memory is applied for according to the reserved memory space occupied capacity.
[0021] In a fourth exemplary implementation, when a memory call request sent by a target application during initialization is detected, applying for a matching target memory from the user-mode memory structure for the target application includes:
[0022] Pre-configure memory allocation and recovery interface;
[0023] When it is detected that the target application sends a memory call request through the memory allocation and recovery interface, the 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 recovery interface;
[0024] The memory usage of the target process is monitored through the memory allocation and recovery interface, and an error is reported when the total memory usage of the target process exceeds the target memory.
[0025] In a fifth exemplary implementation, after caching the target memory into the process space, the method further includes:
[0026] Acquire memory allocation data of a target process currently executing the target application and running status data of each thread included in the target process;
[0027] According to the memory allocation data, the running status data of each thread and the computing resource usage mode, it is determined whether the allocated memory of each thread needs to be migrated to the corresponding non-uniform memory access.
[0028] In a sixth exemplary implementation, determining whether the allocated memory of each thread needs to be migrated to the corresponding non-uniform memory access according to the memory allocation data, the running status data of each thread, and the computing resource usage mode includes:
[0029] Determine, according to the memory allocation data, a first type of target thread to which memory is allocated by specifying non-uniform memory access, and the allocated memory of the first type of target thread is not migrated;
[0030] According to the running status data of each thread and the computing resource usage mode, the 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 where the computing resources it depends on are located.
[0031] Another aspect of the present invention provides a memory allocation device, comprising:
[0032] A memory application module is used to apply for corresponding application-specific memory according to a reserved memory configuration file during memory initialization, and assemble the application-specific memory into a continuous memory space in a manner that the physical addresses are continuous and belong to the same memory device;
[0033] A user-state memory allocation module is used to assemble the continuous memory space into a user-state memory structure in user state according to the memory mapping information of the continuous memory space mapped to the user state under the triggering of a memory application request; when a memory call request sent by a target application during the initialization process is detected, a matching target memory is applied for the target application from the user-state memory structure, and the target memory is cached to the process space for use by the target application.
[0034] The present invention also provides an electronic device, comprising a processor, wherein the processor is used to implement the steps of the memory allocation method as described in any of the preceding items when executing a computer program stored in a memory.
[0035] Finally, the present invention also provides a non-volatile storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the memory allocation method as described in any of the preceding items are implemented.
[0036] The advantage of the technical solution provided by the present invention is that, during the memory initialization process, the kernel-state memory management subsystem reserves memory for use by the application in advance according to the reserved memory configuration file, and then assembles this part of the reserved memory into a data structure that can be used by the user state. The application program applies for memory directly from the pre-allocated memory during operation, and no longer triggers the operating system's memory application-related steps, that is, there is no need to fall into memory-state operations, thereby effectively improving the memory allocation efficiency of the application program, meeting the needs of application scenarios with high real-time requirements, and having better practicality.
[0037] In addition, the present invention also provides a corresponding implementation device, electronic device and non-volatile storage medium for the memory allocation method, which further makes the method more practical, and the device, electronic device and non-volatile storage medium have corresponding advantages.
[0038] The technical features mentioned above, the technical features to be mentioned below, and the technical features shown separately in the drawings can be arbitrarily combined with each other, as long as the combined technical features are not contradictory. All feasible feature combinations are technical contents clearly recorded in this article. Any of the multiple sub-features contained in the same sentence can be applied independently, and does not have to be applied together with other sub-features. It should be understood that the above general description and the detailed description below are only exemplary and cannot limit the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions of the present invention or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0040] Figure 1 A schematic diagram of a flow chart of a memory allocation method provided by the present invention;
[0041] Figure 2 A schematic diagram of the memory initialization process provided by the present invention;
[0042] Figure 3 A schematic diagram of the memory adjustment judgment process provided by the present invention;
[0043] Figure 4 A schematic diagram of a framework of the memory allocation method provided by the present invention in an exemplary application scenario;
[0044] Figure 5 A schematic diagram of a framework of an application layer based on a continuous memory space provided by the present invention in an exemplary application scenario;
[0045] Figure 6 A schematic diagram of the migration process of the memory of an application provided by the present invention in an exemplary application scenario;
[0046] Figure 7 A structural diagram of a specific implementation of the memory allocation device provided by the present invention;
[0047] Figure 8 A structural diagram of a specific implementation of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0048] In order to enable those skilled in the art to better understand the technical solution of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. Among them, the terms "first" and "second" in the specification and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations of the two are intended to cover non-exclusive inclusions. The term "exemplary" means "used as an example, embodiment or illustrative". Any embodiment described here as "exemplary" is not necessarily interpreted as being superior or better than other embodiments.
[0049] The memory management system of the operating system belongs to the kernel state function. The application requests memory from the memory management subsystem in the kernel module of the operating system through brk (system call function) or mmap. The memory management subsystem allocates corresponding memory to the application according to the memory allocation strategy. For example, the memory allocation strategy can be: according to the NUMA (Non Uniform Memory Access) where the CPU (Central Processing Unit) corresponding to the process executing the application is located, the memory on the CPU core of the NUMA is allocated to the application first, and the memory can also be requested from the slab (memory allocation mechanism) or buddy (partner) according to the request size.
[0050] The memory management subsystem efficiently manages and allocates memory resources through mechanisms such as page frame allocator, virtual memory management, Slab (memory allocator name) / SLOB (memory allocator name) / SLUB (memory allocator name) allocator, large page support, NUMA awareness, and cgroups (control groups). Although the memory management subsystem can achieve comprehensive memory management and adapt to various application scenarios. However, in certain specific scenarios, such as high concurrency or a large number of small object allocations, the memory allocation strategy is more complicated to configure and optimize, and the memory allocation efficiency is low. Since the memory management subsystem is in kernel mode, when an application requests memory, the application performance will be reduced due to switching between user mode and kernel mode, page faults, etc. In order to solve this problem and improve the efficiency of memory allocation, related technologies use user-mode memory management tools such as jemalloc (memory allocator name) and tcmalloc (memory allocator name) for on-demand allocation. For example, jemalloc can provide fast and stable memory allocation and memory management functions through multi-threaded friendly design, multi-level page management, low fragmentation technology and efficient memory recovery mechanism. It is suitable for memory allocation of applications that need to efficiently handle a large number of small objects and high concurrency scenarios. However, jemalloc has many configuration items and needs to be tuned to achieve optimal performance. The implementation process is relatively complex and may introduce additional overhead. TCMalloc can significantly reduce lock contention in a multi-threaded environment through thread local caching and paging mechanisms. It is suitable for memory allocation of large-scale multi-threaded applications and can efficiently manage and quickly allocate small object memory. However, TCMalloc is less efficient when processing large blocks of memory, is not flexible enough when optimizing certain specific applications, and its memory usage pattern may result in higher memory usage.
[0051] Related technologies use user-mode memory management tools to allocate memory on demand to applications. When receiving a memory request from an application during the running of the application, this method can complete the memory request from the memory management subsystem through mmap or sbrk. It can be seen that related technologies still need to trigger memory state operations, and there will also be switching between user mode and kernel mode and page faults, resulting in low memory allocation efficiency.
[0052] In view of this, in order to solve the problem that the related art needs to fall into the kernel state when applying for memory for an application, resulting in low memory allocation efficiency, the present invention is to implement a method of reserving physical memory for an application when the memory is initialized, and pre-allocating the memory used by the application when the application is started. The operation of applying for memory during the running of the application is directly applied from the pre-allocated memory, and no longer triggers the memory application related steps of the operating system. By pre-applying for system memory to the process space, this part of the memory no longer participates in the management of the system memory management subsystem, and is only managed by this memory management system, thereby improving the efficiency of the application memory application. After introducing the technical solution of the present invention, various non-limiting embodiments of the present invention are described in detail below. In order to better illustrate the present invention, numerous specific details are given in the specific embodiments below. Those skilled in the art should understand that the present invention can also be implemented without these specific details. In other examples, the methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the main purpose of the present invention.
[0053] First see Figure 1 , Figure 1 A flowchart of a memory allocation method provided in this embodiment may include the following contents:
[0054] S101: During the memory initialization process, a corresponding application-specific memory is applied for according to a reserved memory configuration file, and the application-specific memory is assembled into a continuous memory space in a manner that the physical addresses are continuous and belong to the same memory device.
[0055] The memory initialization process of this step is completed during the initialization process of the kernel memory management subsystem. The memory initialization process can be as follows: Figure 2 As shown, the reserved memory configuration file is file data that records the memory that needs to be reserved for the application on the current server. It can be passed in through the grub (command name) command line. Before memory allocation, memory is reserved according to the reserved memory configuration file to prevent the operating system from allocating it to other processes. For the sake of convenience in description, the memory reserved for the application is defined as application-specific memory, that is, application-specific memory is memory dedicated to the process corresponding to the user program. After applying for a specified amount of memory from the operating system based on the reserved memory configuration file, the memories are assembled according to physical continuity for use by user-mode programs. For the sake of convenience in description, the assembled memory is defined as a continuous memory space, that is, the physical addresses of each memory contained in the continuous memory space are continuous and belong to the same memory device, such as a memory stick.
[0056] S102: In user mode, according to the memory mapping information of the continuous memory space mapped to the user mode triggered by the memory application request, the continuous memory space is assembled to generate a user mode memory structure. When a memory call request sent by the target application during the initialization process is detected, a matching target memory is applied for the target application from the user mode memory structure, and the target memory is cached in the process space for use by the target application.
[0057] After the previous step reserves memory for the application and assembles it into memory space, when the user state applies for memory, the assembled continuous memory space is mapped from the kernel state to the user state, for example, it can be mapped through the mmp method, and then based on the basic information of each mapped memory of the mapped continuous memory space, that is, the memory mapping information, the memory mapping information includes but is not limited to the starting address, physical address, memory size, and NUMA. In order to facilitate the use of the application, the continuous memory space is assembled into a memory structure available to the application, and for the convenience of description, it is defined as a user state memory structure. When a certain application is detected to call memory, in order to avoid distinction, the application that sends the memory call request is defined as the target application, according to the call memory size carried by the memory call request, memory is allocated for the target application from the user state memory structure, and the memory allocated for the target application is defined as the target memory. The target memory can be the same as the call memory carried by the memory call request of the target application, or it can be slightly larger than the call memory carried by the memory call request. Finally, the target memory is cached to the process space corresponding to the process executing the target application. During the operation of the target application, the target memory cached in the process space is allocated to each thread executing the target application.
[0058] In the technical solution provided in this embodiment, the kernel-state memory management subsystem reserves memory for application use in advance according to a reserved memory configuration file during the memory initialization process, and then assembles this part of the reserved memory into a data structure that can be used by the user state. The application program applies for memory directly from the pre-allocated memory during operation, and no longer triggers the operating system's memory application-related steps, i.e., there is no need to fall into memory-state operations, thereby effectively improving the memory allocation efficiency of the application program, meeting the needs of application scenarios with high real-time requirements, and being more practical.
[0059] In the above embodiment, there is no limitation on how to assemble the application-specific program. Based on the above embodiment, the present invention further provides an exemplary implementation method, which may include the following contents:
[0060] Obtain each free memory requested from the operating system, and assemble each free memory into non-consistent memory access, area, and page forms according to the physical address, memory space occupied capacity, memory device identification information, and non-consistent memory access of each free memory, in a manner that the physical address is continuous and belongs to the same memory device, so as to generate a continuous memory space; upon receiving a memory application request, map each memory of the continuous memory space to the user state, and pass the physical address, memory space occupied capacity, and non-consistent memory access of each mapped memory to the user state as memory mapping information.
[0061] In this embodiment, the memory device is such as a memory stick, and the memory device identification information is the number of the memory stick. The basic information of the currently acquired specified amount of memory is identified. The basic information of this embodiment is the physical address of each free memory, the memory space occupied capacity, the memory device identification information and the NUMA to which it belongs, and these information are assembled into NUMA, ZONE (area), and PAGE (page) forms. Memory is applied to the kernel state through a memory application request. The kernel state will assemble continuous memory maps to the user state, together with the mapped address, size and NUMA information, and pass it to the application when the user state needs it, that is, feedback to the application layer. The user state allocates these memories to the thread use and the management of the memory pool according to the initialization strategy, wherein the initialization strategy includes the allocation relationship between memory and thread, the NUMA to which the memory belongs, and the corresponding relationship between memory and cpu core. Further, in order to facilitate monitoring and recording, the memory information applied by the current system can be printed out at the same time, that is, how much memory is applied for which application.
[0062] As an efficient memory allocation method, a user state interface can be pre-configured and provided to the user. When a memory application request is received through the user state interface, each memory of the continuous memory space is mapped to the user state, and the physical address of each mapped memory, the memory space occupancy capacity and the non-consistent memory access to which it belongs are used as memory mapping information and passed to the user state through the user state interface.
[0063] As can be seen from the above, this embodiment assembles a data structure according to basic memory information, and transmits the mapped data structure together with its memory information to the user state through a simple interface, which is conducive to improving memory allocation efficiency.
[0064] In the above embodiment, there is no limitation on how to apply for application-specific memory from the operating system. Based on the above embodiment, the present invention further provides an exemplary implementation method, which may include the following contents:
[0065] The reserved memory configuration file is read, and application-specific memory is requested from the operating system according to the reserved memory configuration file and the priority policy of this embodiment.
[0066] Among them, the reserved memory configuration file may at least include reserved memory configuration information, operating system memory configuration information, and non-consistent memory access allocation information. The reserved memory configuration information includes at least one of the reserved memory ratio or reserved memory space occupied capacity; the non-consistent memory access allocation information includes at least one of the pre-allocated memory ratio on each non-consistent memory access and the pre-allocated memory space occupied capacity on each non-consistent memory access; the operating system memory configuration information includes at least one of the operating system effective memory ratio, operating system effective memory space occupied capacity, operating system effective memory ratio on each non-consistent memory access, and operating system effective memory space occupied capacity on each non-consistent memory access. The user can configure the reserved memory configuration file in any one or more of the above methods according to the actual request. When the reserved memory configuration file has multiple configuration methods at the same time, in order to improve the accuracy and efficiency of memory application, 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 of clear size is higher than the priority of the 100% configuration method, and the priority of the method allocated by NUMA is higher than the priority of the total reserved configuration method.
[0067] Based on the above-mentioned priority configuration method, exemplarily, when the reserved memory configuration file includes the operating system's memory configuration information, the reserved memory configuration information and the non-consistent memory access allocation information at the same time, the corresponding application-specific memory is applied for according to the operating system's memory configuration information; if the operating system's memory configuration information also 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 is applied for according to the operating system's effective memory space occupancy capacity on each non-consistent memory access. application-specific memory; when the reserved memory configuration file includes both the non-consistent memory access allocation information and the reserved memory configuration information, applying for the corresponding application-specific memory according to the non-consistent memory access allocation information; if the non-consistent memory access allocation information includes both the pre-allocated memory ratio of each non-consistent memory access and the occupied capacity of the pre-allocated memory space of each non-consistent memory access, applying for the corresponding application-specific memory according to the occupied capacity of the pre-allocated memory space of each non-consistent memory access; when the reserved memory configuration file includes the reserved memory ratio and the occupied capacity of the reserved memory space, applying for the corresponding application-specific memory according to the occupied capacity of the reserved memory space.
[0068] As can be seen from the above, this embodiment provides users with a variety of memory application configuration methods, which is more flexible and sets different priorities for different configuration methods, effectively improving the accuracy and efficiency of memory application.
[0069] The above embodiment does not limit how to allocate memory to the user program. Based on the above embodiment, the present invention also provides an exemplary implementation method, which may include the following contents:
[0070] A memory allocation and recovery interface is pre-configured; when it is detected that a target application sends a memory call request through the memory allocation and recovery interface, a corresponding target memory is allocated to a target process executing the target application, and the target memory is allocated to the target process through the memory allocation and recovery interface; the memory usage of the target process is monitored through the memory allocation and recovery 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 continuous memory space is mapped to the user state and assembled into a user state memory structure for use by the application, when an application needs to call the memory, the memory allocation and recovery interface can be used to pre-apply for a specified size of memory from the user state memory structure during the initialization phase of the thread running of the process. For efficient use, the applied target memory can be cached in the thread cache for use. In order to improve memory performance and avoid memory usage problems, this embodiment monitors the memory usage of the target application and reports an error immediately when an error occurs, effectively improving the memory access performance of the target application.
[0072] The related technology is that after the application has applied for memory, when the application undergoes NUMA migration due to load problems, kernel state migration is required to migrate the memory resources to the CPU to which it belongs. The so-called kernel state migration means that the operating system will migrate the application according to the system load status during the running of the application, and the memory management subsystem will migrate the memory used by the application to the CPU memory where the application is located. In order to solve the problem that the related technology does not have the memory migration capability and the memory is passively migrated through the memory management subsystem when the application undergoes NUMA migration. The present invention can dynamically adjust the location of the memory allocated and used by the thread during the running of the application to ensure that the memory is always in the best location and the memory access performance is optimal. This embodiment provides a method for memory migration between NUMAs led by an application. When the application undergoes CPU migration, the application determines whether the applied resources need to be migrated and performs active migration, which may include the following contents:
[0073] Obtain the memory allocation data of the target process currently executing the target application and the running status data of each thread contained in the target process; determine whether the allocated memory of each thread needs to be migrated to the corresponding non-consistent memory access based on the memory allocation data, the running status data of each thread and the computing resource usage method.
[0074] The target process refers to the process that executes the target application. The memory allocation data includes how much memory is allocated to each thread of the target process, the NUMA to which the memory belongs, and the memory allocation method. The memory allocation method is to allocate according to the memory to be used by the operating system, to allocate according to the NUMA allocation method, or to allocate with a clear size. The running status data refers to which CPU each thread runs on and which NUMA the CPU belongs to. The computing resource usage method can be the allocation method of the CPU to which each thread belongs. Figure 3As shown, this embodiment can initialize a monitoring thread in the background, and obtain the current memory allocation and the running status information of each thread of the current process in real time or at regular intervals through the monitoring thread, and monitor 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 task allocation is optimal. If not, on the currently running NUMA, it is necessary to determine whether it needs to be adjusted to the NUMA to which the thread belongs. If adjustment is required, an asynchronous migration task is issued for migration. An exemplary judgment method is: according to the memory allocation data, the first type of target thread of the memory allocated by specifying the non-consistent memory access method is determined, and the allocated memory of the first type of target thread is not migrated; according to the running status data of each thread and the computing resource usage method, the 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 resource, the allocated memory of the second type of thread is migrated to the non-consistent memory access where the computing resource it depends on is located. That is to say, if the memory allocated to each thread is fixed, that is, it is allocated through the specified NUMA, then no adjustment is required; if the memory allocated to each thread is allocated according to the CPU to which the thread belongs or automatically allocated, then adjustment is required. When adjusting, count whether the current thread is running on a fixed CPU. If so, further determine whether the correspondence between the current memory and the CPU matches. If not, start the adjustment process to make adjustments, so that the target application can dynamically adjust the group to which the memory belongs according to the thread to which the memory belongs during operation. For example, if 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 cpu1. Thread 2 exists in thread pool 2 and runs on cpu6. The thread pool of thread 2 includes the memory of NUMA1 and the memory of NUMA0. Since thread 2 runs on cpu6, it is necessary to determine whether the memory in thread pool 2 is migrated from memory block 1 to memory block 2. If thread 2 runs on the NUMA where cpu6 is located, the content of memory block 1 is migrated to memory block 2.
[0075] As can be seen from the above, this embodiment dynamically migrates the memory already allocated to the thread to the NUMA where the thread is located according to the change of the thread running state, which is conducive to improving the memory allocation and program running efficiency of applications such as storage software. In addition, the group to which the memory allocated to the application belongs is dynamically adjusted during the running of the application, which can ensure the performance of the application and ensure that the memory access during the running process of the application is always in the optimal state.
[0076] The above embodiment does not limit how to assemble the mapped continuous memory space into a memory structure that can be used by the user. Based on the above embodiment, the present invention also provides a memory structure generation method, which may include the following contents:
[0077] Obtaining the running characteristics and task characteristics of the current application; and selecting a matching memory structure assembly method according to the running characteristics and the task characteristics.
[0078] In this embodiment, when the application is determined to be a program with high real-time requirements based on the running characteristics and the task characteristics, the memory structure can be assembled based on the NUMA method; when the application is a program that requires a large amount of continuous memory, the memory structure can be assembled based on the BUDDY method; when the application is a program that frequently allocates and releases objects, the memory structure can be assembled based on the SLAB method.
[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, each of which is responsible for different types of memory page allocation. The memory pages of each node are allocated by
[0080] The memory structure is managed by the `struct page` array. Each physical page is mapped to a `struct page` object, which contains the status information of the page, such as whether it is allocated, the physical address of the page, etc. Based on the BUDDY method, the memory structure is assembled, and the memory is divided into multiple levels of block linked lists. Each linked list contains continuous memory blocks of a specific size. The size of these memory blocks is a power of 2, ranging from 4KB to 4MB, with a total of 11 levels. That is, the memory block size ranges from 2^0KB (4KB) to 2^10KB (4MB), with a total of 11 levels. Correspondingly, there are 11 linked lists to manage memory blocks of different sizes. When allocating memory, the system will first find free blocks from the linked list of the corresponding size. If there are no free blocks, it will look up for a larger linked list and split the large block of memory into small blocks. When reclaiming memory, the system will merge the memory blocks into the corresponding linked list. When the memory structure is assembled based on the SLAB method, the memory can be divided into multiple cache pools, each of which contains objects of a specific size. The objects in each cache pool are divided into three states: free, partially used, and fully used. When an object needs to be allocated, it can be obtained 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 the effectiveness, but also improve the memory allocation efficiency and memory management efficiency.
[0082] In order to make the embodiments of the present invention more clear to those skilled in the art, the present invention also provides an exemplary memory management system, which may include the following contents:
[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 continuous memory space, and a memory application driver layer in kernel mode. Figure 6 As shown, the application layer based on the continuous memory space may include a memory allocation and recovery interface, a user-mode memory structure, a memory application module, and a memory migration module.
[0084] The memory application driver layer is used to apply for a specified amount of free memory from the operating system during memory initialization, identify the basic information of the specified amount of memory currently obtained, and assemble this information into NUMA, ZONE, and PAGE forms according to physical continuity to obtain continuous memory space for user-mode programs to use. The memory application driver layer provides a user-mode interface to the user-mode and prints out the applied memory information.
[0085] The thread-based application layer applies for memory from the kernel state through the user state interface, maps the continuous memory space applied from the kernel state to the user state, assembles the memory into a user state memory structure available to the application according to concepts such as NUMA, PAGE, BUDDY, SLAB, etc., and allocates the memory to threads for use and memory pool management according to the initialization strategy. Figure 6 As shown in the figure, it provides a memory allocation and recovery interface for the thread-based application layer, and dynamically migrates the thread-allocated memory to the NUMA to which the thread belongs based on the change of the thread running state through the memory migration module. The thread-based application layer is used to apply for and release memory for the application's threads, and when memory migration is required, migrate the thread's allocated memory to the NUMA to which the CPU belongs.
[0086] From the above, it can be seen that the memory management system provided in this embodiment adopts memory pre-allocation to apply for the memory required by the application to the application space in advance, and can migrate the memory to the NUMA to which the running CPU belongs during the running of the application, thereby effectively improving the performance of the application and ensuring that the memory access during the running process of the application is always in the optimal state.
[0087] It should be noted that there is no strict order of execution between the steps in the present invention. As long as they comply with the logical order, these steps can be executed simultaneously or in a certain preset order. Figure 1-Figure 3 This is just a schematic and does not mean that this is the only execution order.
[0088] The present invention also provides a corresponding device for the memory allocation method, which further makes the method more practical. Among them, the device can be described from the perspective of functional modules and hardware. The memory allocation device provided by the present invention is introduced below. The device is used to implement the memory allocation method provided by the present invention. In this embodiment, the memory allocation device may include or be divided into one or more program modules, and the 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 Example 1. The program module referred to in this embodiment refers to a series of computer program instruction segments that can complete specific functions, which is more suitable for describing the execution process of the memory allocation device in the storage medium than the program itself. The following description will specifically introduce the functions of each program module in this embodiment. The memory allocation device described below and the memory allocation method described above can be referenced to each other.
[0089] From the perspective of functional modules, see Figure 7 , Figure 7 A structural diagram of a memory allocation device provided in this embodiment in a specific implementation manner, the device may include:
[0090] The memory application module 701 is used to apply for corresponding application-specific memory according to the reserved memory configuration file during the memory initialization process, and assemble the application-specific memory into a continuous memory space in a manner that the physical addresses are continuous and belong to the same memory device.
[0091] The user-state memory allocation module 702 is used to assemble the continuous memory space into a user-state memory structure in the user state according to the memory mapping information of the continuous memory space mapped to the user state under the triggering of the memory application request; when a memory call request sent by the target application during the initialization process is detected, a matching target memory is applied for the target application from the user-state memory structure, and the target memory is cached to the process space for use by the target application.
[0092] Illustratively, in some implementations of this embodiment, the memory application module 701 may also be used to:
[0093] Obtain each free memory requested from the operating system, and assemble each free memory into non-consistent memory access, area, and page forms according to the physical address, memory space occupied capacity, memory device identification information, and non-consistent memory access of each free memory, in a manner that the physical address is continuous and belongs to the same memory device, so as to generate a continuous memory space; upon receiving a memory application request, map each memory of the continuous memory space to the user state, and pass the physical address, memory space occupied capacity, and non-consistent memory access of each mapped memory to the user state as memory mapping information.
[0094] As an exemplary implementation of the above embodiment, the memory application module 701 may also be used for:
[0095] A user state interface is preconfigured; when a memory application request is received through the user state interface, each memory of the continuous memory space is mapped to the user state, and the physical address of each mapped memory, the memory space occupied capacity and the non-consistent memory access to which it belongs are used as memory mapping information and transmitted to the user state through the user state interface.
[0096] Illustratively, in some other implementations of this embodiment, the memory application module 701 may also be used to:
[0097] Read a reserved memory configuration file; the reserved memory configuration file includes at least reserved memory configuration information, operating system memory configuration information, and non-consistent memory access allocation information; the reserved memory configuration information includes a reserved memory ratio and a reserved memory space occupied capacity; the non-consistent memory access allocation information includes a pre-allocated memory ratio for each non-consistent memory access and a pre-allocated memory space occupied capacity for each non-consistent memory access; the operating system memory configuration information includes an operating system effective memory ratio, an operating system effective memory space occupied capacity, an operating system effective memory ratio for each non-consistent memory access, and an operating system effective memory space occupied capacity for each non-consistent memory access;
[0098] When the reserved memory configuration file includes the memory configuration information used by the operating system, the reserved memory configuration information and the non-consistent memory access allocation information at the same time, the corresponding application-specific memory is applied for according to the memory configuration information used by the operating system; if the memory configuration information used by the operating system includes the operating system's effective memory ratio, the operating system's effective memory space ratio, the operating system's effective memory ratio on each non-consistent memory access, and the operating system's effective memory space occupancy capacity on each non-consistent memory access, the corresponding application-specific memory is applied for according to the operating system's effective memory space occupancy capacity on each non-consistent memory access;
[0099] When the reserved memory configuration file includes both the non-consistent memory access allocation information and the reserved memory configuration information, the corresponding application-specific memory is applied for according to the non-consistent memory access allocation information; if the non-consistent memory access allocation information includes both the pre-allocated memory ratio of each non-consistent memory access and the occupied capacity of the pre-allocated memory space of each non-consistent memory access, the corresponding application-specific memory is applied for according to the occupied capacity of the pre-allocated memory space of each non-consistent memory access;
[0100] When the reserved memory configuration file includes the reserved memory percentage and the reserved memory space occupied capacity, the corresponding application-specific memory is applied for according to the reserved memory space occupied capacity.
[0101] Illustratively, in some other implementations of this embodiment, the user-mode memory allocation module 702 may also be used for:
[0102] A memory allocation and recovery interface is pre-configured; when it is detected that a target application sends a memory call request through the memory allocation and recovery interface, a corresponding target memory is allocated to a target process executing the target application, and the target memory is allocated to the target process through the memory allocation and recovery interface; the memory usage of the target process is monitored through the memory allocation and recovery interface, and an error is reported when the total memory usage of the target process exceeds the target memory.
[0103] Exemplarily, in some other implementations of this embodiment, the above device may further include a memory adjustment migration module, which may be used to:
[0104] Acquire memory allocation data of a target process currently executing the target application and running status data of each thread included in the target process;
[0105] According to the memory allocation data, the running status data of each thread and the computing resource usage mode, it is determined whether the allocated memory of each thread needs to be migrated to the corresponding non-uniform memory access.
[0106] As an exemplary implementation of the above embodiment, the above memory adjustment migration module may also be used for:
[0107] A first type of target thread to which memory is allocated by specifying non-consistent memory access is determined according to the memory allocation data, and the allocated memory of the first type of target thread is not migrated; a second type of target thread to which fixed computing resources are used is determined according to the running status data of each thread and the way computing resources are used, and if the allocated memory of the second type of thread does not match the corresponding dependent computing resource, the allocated memory of the second type of thread is migrated to the non-consistent memory access where the computing resource on which it depends is located.
[0108] The memory allocation device mentioned above is described from the perspective of functional modules. Furthermore, the present invention also provides an electronic device, which is described from the perspective of hardware. Figure 8 The following is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention in one implementation manner. Figure 8As shown, the electronic device includes a memory 80 for storing computer programs; a processor 81 for implementing the steps of the memory allocation method mentioned in any of the above embodiments when executing the computer program.
[0109] Among them, the processor 81 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and the processor 81 may also be a controller, a microcontroller, a microprocessor or other data processing chip. The processor 81 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 81 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 81 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 81 may also include an AI (Artificial Intelligence) processor, which is used to process computing 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 and flash memory storage devices. In some embodiments, the memory 80 may be an internal storage unit of an electronic device, such as a hard disk of a server. In other embodiments, the memory 80 may also be an external storage device of an electronic device, such as a plug-in hard disk equipped on a server, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Further, the memory 80 may also include both an internal storage unit of an electronic device and an external storage device. The memory 80 may not only be used to store application software and various types of data installed in the electronic device, such as: the code of the program in the process of executing the memory allocation method, etc., but may also be used to temporarily store data that has been output or is to be output. In this embodiment, the memory 80 is at least used to store the following computer program 801, wherein, after the computer program is loaded and executed by the processor 81, the relevant steps of the memory allocation method disclosed in any of the aforementioned embodiments can be implemented. In addition, the resources stored in the memory 80 may also include an operating system 802 and data 803, and the storage method may be temporary storage or permanent storage. The operating system 802 may include Windows, Unix, Linux, etc. The data 803 may include but is not limited to data corresponding to the memory allocation result.
[0111] In some embodiments, the electronic device may further include a display screen 82, an input / output interface 83, a communication interface 84 or a network interface, a power supply 85 and a communication bus 86. Among them, the display screen 82 and the input / output interface 83 such as a keyboard belong to the user interface, and 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, and an OLED (Organic Light-Emitting Diode) touch device, etc. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device and to display a visual user interface. The communication interface 84 may exemplarily include a wired interface and / or a wireless interface, such as a WI-FI interface, a Bluetooth interface, etc., which are generally used to establish a communication connection 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. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0112] Those skilled in the art will understand that Figure 8 The structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, for example, it may also include a sensor 87 to implement various functions.
[0113] It is understandable that if the memory allocation method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile storage medium. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the relevant technology or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes but is not limited to: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), electrically erasable programmable ROM, register, hard disk, multimedia card, card-type memory (such as SD or DX memory, etc.), magnetic memory, removable disk, CD-ROM, magnetic disk or optical disk, etc. Various media that can store program codes. Based on this, the present invention also provides a non-volatile storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the memory allocation method recorded in any of the above embodiments.
[0114] It is understandable that if the memory allocation method in the above embodiment is implemented in the form of 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 through a wired network or a wireless network to execute all or part of the steps of the methods of each embodiment of the present invention. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the relevant 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 described in any of the above embodiments.
[0115] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the hardware disclosed in the embodiments, including devices, electronic devices, and non-volatile storage media, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0116] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0117] The above is a detailed introduction to a memory allocation method, device, electronic device and non-volatile storage medium provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. It should be pointed out that based on the embodiments of the present invention, for ordinary technicians in this technical field, all other embodiments obtained without creative work are within the scope of protection of the present invention. Without departing from the principles of the present invention, the present invention can also be improved and modified in a number of ways, 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 the memory initialization process, the corresponding application-specific memory is applied for according to the reserved memory configuration file, and the application-specific memory is assembled into a continuous memory space in a manner that the physical addresses are continuous and belong to the same memory device; In the user state, according to the memory mapping information of the continuous memory space mapped to the user state triggered by the memory application request, the continuous memory space is assembled to generate a user state memory structure; When a memory call request sent by a target application during initialization is detected, a matching target memory is requested from the user-mode memory structure for the target application, and the target memory is cached in a process space for use by the target application.
2. The memory allocation method according to claim 1, characterized in that: The step of assembling the application-specific memory into a continuous memory space in a manner that the physical addresses are continuous and belong to the same memory device includes: Obtain each free memory requested from the operating system, and assemble each free memory into non-consistent memory access, region, and page forms according to the physical address, memory space occupied capacity, memory device identification information, and non-consistent memory access of each free memory, in a manner that the physical address is continuous and belongs to the same memory device, so as to generate a continuous memory space; Upon receiving a memory application request, each memory of the continuous memory space is mapped to the user state, and the physical address of each mapped memory, the memory space occupied capacity and the non-consistent memory access to which it belongs are transmitted to the user state as memory mapping information.
3. The memory allocation method according to claim 2, characterized in that: Upon receiving a memory application request, mapping each memory of the continuous memory space to a user state, and transmitting the physical address of each memory after mapping, the memory space occupied capacity and the non-consistent memory access to which it belongs as memory mapping information to the user state, including: Pre-configure user-mode interfaces; When a memory application request is received through the user state interface, each memory of the continuous memory space is mapped to the user state, and the physical address of each mapped memory, the memory space occupied capacity and the non-consistent memory access to which it belongs are used as memory mapping information and transmitted to the user state through the user state interface.
4. The memory allocation method according to claim 1, characterized in that: The applying for corresponding application-specific memory according to the reserved memory configuration file includes: Read a reserved memory configuration file; the reserved memory configuration file includes at least one of the reserved memory configuration information, the operating system memory configuration information, and the non-consistent memory access allocation information; the reserved memory configuration information includes the reserved memory ratio and the reserved memory space occupied capacity; the non-consistent memory access allocation information includes the pre-allocated memory ratio on each non-consistent memory access and the pre-allocated memory space occupied capacity on each non-consistent memory access; the operating system memory configuration information includes the operating system effective memory ratio, the operating system effective memory space occupied capacity, the operating system effective memory ratio on each non-consistent memory access, and the operating system effective memory space occupied capacity on each non-consistent memory access; When the reserved memory configuration file includes the memory configuration information used by the operating system, the reserved memory configuration information and the non-consistent memory access allocation information at the same time, the corresponding application-specific memory is applied for according to the memory configuration information used by the operating system; if the memory configuration information used by the operating system includes the operating system's effective memory ratio, the operating system's effective memory space ratio, the operating system's effective memory ratio on each non-consistent memory access, and the operating system's effective memory space occupancy capacity on each non-consistent memory access, the corresponding application-specific memory is applied for according to the operating system's effective memory space occupancy capacity on each non-consistent memory access; When the reserved memory configuration file includes both the non-consistent memory access allocation information and the reserved memory configuration information, the corresponding application-specific memory is applied for according to the non-consistent memory access allocation information; if the non-consistent memory access allocation information includes both the pre-allocated memory ratio of each non-consistent memory access and the occupied capacity of the pre-allocated memory space of each non-consistent memory access, the corresponding application-specific memory is applied for according to the occupied capacity of the pre-allocated memory space of each non-consistent memory access; When the reserved memory configuration file includes the reserved memory ratio and the reserved memory space occupied capacity, the corresponding application-specific memory is applied for according to the reserved memory space occupied capacity.
5. The memory allocation method according to claim 1, characterized in that: When a memory call request sent by the target application during the initialization process is detected, applying for a matching target memory from the user state memory structure for the target application includes: Pre-configure memory allocation and recovery interface; When it is detected that the target application sends a memory call request through the memory allocation and recovery interface, the 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 recovery interface; The memory usage of the target process is monitored through the memory allocation and recovery interface, and an error is reported when the total memory usage of the target process exceeds the target memory.
6. The memory allocation method according to any one of claims 1 to 5, characterized in that: After caching the target memory into the process space, the method further includes: Acquire memory allocation data of a target process currently executing the target application and running status data of each thread included in the target process; According to the memory allocation data, the running status data of each thread and the computing resource usage mode, it is determined whether the allocated memory of each thread needs to be migrated to the corresponding non-uniform memory access.
7. The memory allocation method according to claim 6, characterized in that: The determining, based on the memory allocation data, the running status data of each thread and the computing resource usage mode, whether the allocated memory of each thread needs to be migrated to the corresponding non-uniform memory access includes: Determine, according to the memory allocation data, a first type of target thread to which memory is allocated by specifying non-uniform memory access, and the allocated memory of the first type of target thread is not migrated; According to the running status data of each thread and the computing resource usage mode, the 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 where the computing resources it depends on are located.
8. A memory allocation device, characterized in that: include: A memory application module is used to apply for corresponding application-specific memory according to a reserved memory configuration file during memory initialization, and assemble the application-specific memory into a continuous memory space in a manner that the physical addresses are continuous and belong to the same memory device; A user state memory allocation module is used to assemble the continuous memory space to generate a user state memory structure in the user state according to the memory mapping information of the continuous memory space mapped to the user state under the triggering of the memory application request; When a memory call request sent by a target application during initialization is detected, a matching target memory is requested from the user-mode memory structure for the target application, and the target memory is cached in a process space for use by the target application.
9. An electronic device, characterized in that: It comprises a processor and a memory, wherein the processor is used to implement the steps of the memory allocation method as claimed in any one of claims 1 to 7 when executing a computer program stored in the memory.
10. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the memory allocation method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Memory reservation method and apparatus
CN106708752A
Memory management method and device, computer equipment and storage medium
CN116302491A
Memory allocation method and device
CN117806825A
Memory allocation method and device, electronic equipment and storage medium
CN119025270A
Memory allocation method, apparatus and system
WO2022237624A1
Cited By
Memory resource allocation method and device, electronic equipment, medium and product
CN120407201A
Memory access method, chip system, electronic equipment and program
CN120687373A
User mode memory management method, product, electronic equipment and storage medium
CN120849136A
Memory allocation method and electronic equipment
CN121166380A