Memory allocation method and system, and electronic device and storage medium

By determining the capacity and location information of the memory to be allocated in the operating system and adopting a small-block memory management approach, the I/O overhead problem caused by the 4k memory swap granularity in the existing technology is solved, and efficient memory allocation and improved resource utilization are achieved.

WO2026066784A1PCT designated stage Publication Date: 2026-04-02CLOUD INTELLIGENCE ASSETS HOLDING (SINGAPORE) PTE LTD +1
View PDF 4 Cites 0 Cited by

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2025-08-14
Publication Date
2026-04-02

AI Technical Summary

Technical Problem

In current operating systems, memory swapping is granular at 4k, which means that even if a process only needs to swap a portion of the pages, the entire page will be swapped out, increasing I/O overhead, making it impossible to allocate memory effectively to save large pages that have not been swapped out, and limiting the efficient use of memory.

Method used

By determining the capacity of the memory to be allocated, finding the target metadata that matches the capacity, determining the location information of the memory to be allocated, and allocating the memory corresponding to the compressed data from the memory pool based on the location information, the memory compression method is used to reduce memory usage and transmission overhead, thereby achieving efficient management of small memory blocks.

Benefits of technology

It improves the performance and resource utilization of the operating system, supports memory swapping and compression operations in a virtualized environment, ensures the effective storage and exchange of compressed data between physical memory and virtual memory, and solves the problem of ineffective memory allocation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025114823_02042026_PF_FP_ABST
    Figure CN2025114823_02042026_PF_FP_ABST
Patent Text Reader

Abstract

Disclosed in the embodiments of the present disclosure are a memory allocation method and system, and an electronic device and a storage medium. The method comprises: determining the capacity of a memory to be allocated, wherein said memory is configured to store compressed data, which is used for indicating a compression result of data exchanged between a physical memory and a virtual memory; searching a structure for target metadata that matches the capacity, wherein the structure at least comprises metadata of different memories in a memory pool; on the basis of the target metadata, determining position information of the memory to be allocated, wherein the position information is used for indicating the position of the memory to be allocated in the memory pool corresponding to the structure; and on the basis of the position information, allocating from the memory pool the memory corresponding to the compressed data. The present disclosure solves the technical problem of failing to effectively allocate memory.
Need to check novelty before this filing date? Find Prior Art

Description

Memory allocation method, system, electronic device and storage medium

[0001] Cross-reference to related applications

[0002] The present disclosure claims priority to the Chinese patent application No. 2024113722476, filed on September 27, 2024, and entitled "Memory allocation method, system, electronic device and storage medium", the entire content of which is incorporated herein by reference. TECHNICAL FIELD

[0003] The present disclosure relates to the field of computer, in particular, to a memory allocation method, system, electronic device and storage medium. BACKGROUND

[0004] Currently, in the operating system, memory swapping refers to storing the page data temporarily unnecessary in the memory to the disk to release the memory space for other needed pages. This process relies on the Least Recently Used (LRU) algorithm and the swap function of the operating system. The LRU algorithm is used to determine which pages are the least recently accessed, so as to select which pages need to be swapped out. And the swap function is used to write the selected page data to the disk, and swap it into the memory when needed.

[0005] However, in the above operating system, the granularity of memory swapping is usually 4k, that is, swapping in page (memory page) units. This means that even if only part of the page needs to be swapped out, the entire page will be swapped out, increasing the overhead of Input / Output (I / O or IO) operations. That is, the current operating system can only support small page memory page interaction in the internal swap function, and cannot be applied to the large page scenario. The above situation may cause the memory to be unable to be effectively allocated to save the unswapped large page during data swapping, thereby limiting the effective use of memory. Therefore, there is still a technical problem that the memory cannot be effectively allocated.

[0006] At present, there is no effective solution to the above problem. SUMMARY

[0007] The embodiments of the present disclosure provide a memory allocation method, system, electronic device and storage medium to at least solve the technical problem that the memory cannot be effectively allocated.

[0008] According to an aspect of embodiments of the present disclosure, a memory allocation method is provided. The method can include determining a capacity of a memory to be allocated, wherein the memory to be allocated is used to store compressed data, and the compressed data is used to represent a compression result of data exchanged between a physical memory and a virtual memory; searching, in a structure, target metadata matching the capacity, wherein the structure includes at least metadata of different memories in a memory pool; determining, based on the target metadata, location information of the memory to be allocated, wherein the location information is used to represent a location of the memory to be allocated in a memory pool corresponding to the structure; and allocating, based on the location information, memory corresponding to the compressed data from the memory pool.

[0009] According to another aspect of embodiments of the present disclosure, a memory release method is provided. The method can include determining, in a memory pool corresponding to a structure, a memory to be released, wherein the memory to be released is obtained from the memory pool based on location information, and is used to store compressed data; the compressed data is used to represent a compression result of data exchanged between a physical memory and a virtual memory; the location information is used to represent a location of the memory to be released in the memory pool corresponding to the structure, and the location information is determined based on target metadata; the target metadata is metadata matching a capacity of the memory to be released, and is searched in the structure; and performing a release operation on the memory to be released.

[0010] According to another aspect of embodiments of the present disclosure, a memory allocation method is provided. The method can include determining data exchanged between a physical memory and a virtual memory; compressing the data to obtain compressed data; determining a capacity of a memory to be allocated based on the compressed data, wherein the memory to be allocated is used to store the compressed data; searching, in a structure, target metadata matching the capacity, wherein the structure includes at least metadata of different memories in a memory pool; determining, based on the target metadata, location information of the memory to be allocated, wherein the location information is used to represent a location of the memory to be allocated in a memory pool corresponding to the structure; and allocating, based on the location information, memory corresponding to the compressed data from the memory pool.

[0011] According to another aspect of the embodiments of the present disclosure, a memory allocation system is also provided. The system can include: a memory allocation end configured to determine a capacity of a memory to be allocated, wherein the memory to be allocated is configured to store compressed data, and the compressed data is configured to represent a compression result of data exchanged between a physical memory and a virtual memory; find target metadata matching the capacity in a structure, wherein the structure includes at least metadata of different memories in a memory pool; determine location information of the memory to be allocated based on the target metadata, wherein the location information is configured to represent a location of the memory to be allocated in a memory pool corresponding to the structure; allocate the memory corresponding to the compressed data from the memory pool based on the location information; and a memory release end configured to perform a release operation on the memory corresponding to the compressed data.

[0012] According to another aspect of the embodiments of the present disclosure, an electronic device is also provided. The electronic device can include a memory and a processor, wherein the memory is configured to store computer-executable instructions, and the processor is configured to execute the computer-executable instructions, and when the computer-executable instructions are executed by the processor, the above-mentioned method of the embodiments of the present disclosure is implemented.

[0013] According to another aspect of the embodiments of the present disclosure, a processor is also provided. The processor is configured to run a program, and when the program is running, the above-mentioned method of the embodiments of the present disclosure is executed.

[0014] According to another aspect of the embodiments of the present disclosure, a computer-readable storage medium is also provided. The computer-readable storage medium includes a stored program, and when the program is running, the device where the storage medium is located is controlled to execute the above-mentioned method of the embodiments of the present disclosure.

[0015] According to another aspect of the embodiments of the present disclosure, a computer program product is also provided. The computer program product includes a computer program, and when the computer program is executed by a processor, the above-mentioned method of the embodiments of the present disclosure is implemented.

[0016] In the embodiment of the present disclosure, in the memory exchange process, the to-be-allocated memory storing compressed data of data used for exchange between the physical memory and the virtual memory can be obtained, and the capacity of the to-be-allocated memory can be determined. Since the memory pool in the structure includes metadata of different memories, the metadata matching the capacity can be queried as target metadata in the metadata in the structure. The position information of the to-be-allocated memory in the memory pool corresponding to the structure can be determined according to the target metadata, and the memory corresponding to the compressed data can be allocated from the memory pool according to the position information, so as to realize memory allocation. In the embodiment, the compressed memory is used to reduce memory occupation and transmission overhead. In the memory exchange process, the small block of memory after compression can be more efficiently stored and transmitted, so as to improve the performance and resource utilization of the operating system, and the small block of memory management can better support the memory exchange and compression operation in the virtualization environment, so as to realize more efficient memory exchange and data transmission. Through the above structured memory management manner, the effective storage and exchange of the compressed data between the physical memory and the virtual memory are ensured. Through the processes of querying the target metadata, determining the position information, and allocating the memory, the effective management and allocation of the compressed data are realized, the performance and efficiency of the operating system are improved, and the technical effect that the memory can be effectively allocated is realized, and the technical problem that the memory cannot be effectively allocated is solved.

[0017] It is easy to note that the general description above and the detailed description below are only for exemplifying and explaining the present disclosure, and do not constitute the limitation of the present disclosure. BRIEF DESCRIPTION OF DRAWINGS

[0018] The drawings described herein are used to provide further understanding of the present disclosure, constitute a part of the present disclosure, and the illustrative embodiments of the present disclosure and the description thereof are used to explain the present disclosure, and do not constitute the improper limitation of the present disclosure. In the drawings:

[0019] Fig. 1 is a hardware structure block diagram of a computer terminal (or mobile device) for implementing a memory allocation method according to an embodiment of the present disclosure;

[0020] Fig. 2 is a structure block diagram of a computing environment of a memory allocation method according to an embodiment of the present disclosure;

[0021] Fig. 3 is a flowchart of a memory allocation method according to an embodiment of the present disclosure;

[0022] Fig. 4 is a flowchart of a memory release method according to an embodiment of the present disclosure;

[0023] Fig. 5 is a flowchart of another memory allocation method according to an embodiment of the present disclosure;

[0024] Fig. 6 is a schematic diagram of a memory allocation system according to an embodiment of the present disclosure;

[0025] Fig. 7(a) is a flow chart of a method of managing small block memory according to an embodiment of the present disclosure;

[0026] Fig. 7(b) is a flow chart of a method of allocating small block memory according to an embodiment of the present disclosure;

[0027] Fig. 7(c) is a flow chart of a method of releasing small block memory according to an embodiment of the present disclosure;

[0028] Fig. 8 is a schematic diagram of a memory allocation apparatus according to an embodiment of the present disclosure;

[0029] Fig. 9 is a schematic diagram of a memory release apparatus according to an embodiment of the present disclosure;

[0030] Fig. 10 is a schematic diagram of another memory allocation apparatus according to an embodiment of the present disclosure;

[0031] Fig. 11 is a structural block diagram of a computer terminal according to an embodiment of the present disclosure;

[0032] Fig. 12 is a block diagram of an electronic device for a memory allocation method according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0033] In order to make the persons skilled in the art better understand the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work should fall within the scope of the present disclosure.

[0034] It should be noted that the terms "first", "second", and the like in the specification and claims of the present disclosure and the above-described drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present disclosure described herein can be implemented in other than the order illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or components does not necessarily limit to those steps or components clearly listed, but can include other steps or components not clearly listed or inherent to such processes, methods, products or devices.

[0035] First, some of the nouns or terms appearing in the description of the embodiments of the present disclosure are applicable to the following explanations:

[0036] swap function (swap mechanism), a mechanism in the operating system that can use free hard disk space as memory expansion. When the physical memory is insufficient, the swap mechanism moves the infrequently used memory pages to the hard disk to release space for other pages to use;

[0037] Page swap out (swap out) refers to the process of moving infrequently used pages in memory to the hard disk to free up space;

[0038] Page swap in (swap in) refers to the process of reloading the page moved to the hard disk into memory when the process accesses it again. The swap mechanism includes two aspects: swap partition and swap file;

[0039] Swap partition is a hard disk space dedicated to swap operations. By mounting and activating, it can help the system handle memory shortage. Swap partition has the advantages of fast speed and high stability, but needs to be planned in advance. The size cannot be dynamically adjusted. Reasonable configuration of the swap partition can improve the performance and stability of the system. The advantages of the swap partition are fast speed and high stability, but the partition size needs to be planned in advance and cannot be dynamically adjusted.

[0040] According to the embodiments of the present disclosure, a memory allocation method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0041] The method embodiments provided by the embodiments of the present disclosure can be executed in a mobile terminal, a computer terminal or a similar computing device. FIG. 1 is a hardware structure block diagram of a computer terminal (or a mobile device) for implementing a memory allocation method according to an embodiment of the present disclosure. As shown in FIG. 1, the computer terminal 10 (or a mobile device) can include one or more processors 102 (the processor 102 can include, but is not limited to, a processing device such as a microcontroller unit (MCU) or a field programmable gate array (FPGA)), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it can also include a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which can be included as one of the ports of the bus), a network interface, a power supply and / or a camera. Those skilled in the art can understand that the structure shown in FIG. 1 is only schematic and does not limit the structure of the above-mentioned electronic device. For example, the computer terminal 10 can include more or fewer components than those shown in FIG. 1, or have a different configuration from that shown in FIG. 1.

[0042] The hardware structure block diagram shown in FIG. 1 can not only be used as an exemplary block diagram of the above-mentioned computer terminal 10 (or a mobile device), but also as an exemplary block diagram of the above-mentioned server. In an optional embodiment, FIG. 2 shows an embodiment using the computer terminal 10 (or a mobile device) shown in FIG. 1 as a computing node in a computing environment 201.

[0043] FIG. 2 is a structure block diagram of a computing environment for a memory allocation method according to an embodiment of the present disclosure. As shown in FIG. 2, the computing environment 201 includes a plurality of computing nodes (such as servers) running on a distributed network. The computing nodes all contain local processing and memory resources, and an end user 202 can remotely run an application or store data in the computing environment 201. The application can be provided as a plurality of services 220-1, 220-2, 220-3 and 220-4 in the computing environment 201, representing services “A”, “D”, “E” and “H” respectively.

[0044] End users 202 can provide and access services through a web browser or other software application on a client, in some embodiments, provisioning and / or requests of end users 202 can be provided to ingress gateway 230. Ingress gateway 230 can include a corresponding proxy to handle provisioning and / or requests for services (one or more services provided in computing environment 201).

[0045] Services are provided or deployed according to various virtualization technologies supported by computing environment 201. In some embodiments, services can be provided according to virtual machine (VM)-based virtualization, container-based virtualization, and / or the like. Virtual machine-based virtualization can emulate a real computer by initializing a virtual machine to execute programs and applications without directly accessing any actual hardware resources. While a virtual machine virtualization machine, according to container-based virtualization, a container can be launched to virtualize an entire operating system so that multiple workloads can run on a single operating system instance.

[0046] In one embodiment of container-based virtualization, several containers of a service can be assembled into a Pod (e.g., a Kubernetes Pod). For example, as shown in FIG. 2, service 220-2 can be equipped with one or more Pods 240-1, 240-2, …, 240-N (collectively, Pods). A Pod can include a proxy 245 and one or more containers 242-1, 242-2, …, 242-M (collectively, containers). The one or more containers in a Pod handle requests related to one or more corresponding functions of a service, and proxy 245 generally controls network functions related to the service, such as routing, load balancing, and the like. Other services can also be equipped with Pods similar to Pods.

[0047] In operation, executing a user request from end user 202 can require invoking one or more services in computing environment 201, and executing one or more functions of a service can require invoking one or more functions of another service. As shown in FIG. 2, service “A” 220-1 receives a user request from end user 202 from ingress gateway 230, service “A” 220-1 can invoke service “D” 220-2, and service “D” 220-2 can request service “E” 220-3 to execute one or more functions.

[0048] The computing environment described above can be a cloud computing environment, the allocation of resources is managed by a cloud service, allowing the development of functions without considering the implementation, adjustment or expansion of servers. The computing environment allows developers to execute code that responds to events without building or maintaining complex infrastructure. Services can be divided into a set of functions that can automatically scale independently, rather than expanding a single hardware device to handle potential loads.

[0049] In the above running environment, the disclosure provides a memory allocation method as shown in FIG. 3, which can be applied to an optical transmission system, and an optical switch is deployed on a transmission link of the optical transmission system. It should be noted that the memory allocation method of the embodiment can be executed by the mobile terminal of the embodiment shown in FIG. 1. FIG. 3 is a flowchart of a memory allocation method according to an embodiment of the disclosure, as shown in FIG. 3, the method can include the following steps:

[0050] Step S302, determine the capacity of the memory to be allocated.

[0051] In the technical solution provided in step S302 of the disclosure, the memory to be allocated can be used to store compressed data, can be a memory block (Memory Segment, referred to as ms) in a memory pool, and can be a small piece of memory to be allocated. The memory block is a small area obtained by cutting a large block of memory according to a certain granularity, which is usually divided into a large memory size, such as 2m. Each ms can be divided into a plurality of memory pages (Memory Page, referred to as mp), and the memory page can also be referred to as a memory page. The memory page is a small block of memory obtained by further cutting the memory block, which is usually divided into a small memory size, such as 4k. Each mp contains a plurality of memory chunks (small memory chunks). The ms is the most basic unit of memory management, the mp is a further division of the ms, and the chunk is the smallest allocation unit of the mp.

[0052] Optionally, the memory pool can contain a plurality of types of memory allocation algorithms and data structures for describing different memory allocation requirements, which can be a zero buddy (Zero Buddy, referred to as zbud) pool. The zbud pool is an implementation of the memory pool, which is used to manage the allocation and release of low-end memory, uses the Zero Buddy algorithm to manage memory, and provides efficient memory management functions.

[0053] It should be noted that the above only exemplifies the division unit size of the divided ms and the divided mp, which is not specifically limited here.

[0054] In the embodiments of the present disclosure, the physical memory management granularity of the underlying virtualization layer is 2m, which means that in the virtualization environment, the memory is divided into 2m-sized blocks for management. Since the memory pool is a tool for memory allocation and release in the virtualization layer, it also operates the memory blocks in 2m granularity. The beneficial effect of the above management manner is to keep the virtualization layer and the main memory management granularity consistent, which can facilitate memory interaction operation. Using the same 2m granularity to manage memory can ensure that the memory management between the underlying virtualization layer and the zbud is consistent. In this way, memory management confusion and errors caused by inconsistent granularity can be avoided. Since the virtualization layer and the zbud both manage memory in 2m granularity, the memory interaction between them will be more convenient and efficient. Based on this, the granularity conversion and processing in the memory interaction process can be reduced, and the efficiency of memory operation can be improved. By uniformly managing memory in granularity, the process and operation of memory management can be simplified. Managing fewer 2m memory blocks can reduce the workload of the memory manager compared to 4k granularity, and improve the performance and efficiency of the system. In summary, keeping the memory management granularity of the underlying virtualization layer and the zbud consistent in the embodiments of the present disclosure is an effective technical strategy, which can improve the consistency and efficiency of memory management, simplify memory interaction operation, reduce memory management overhead, thereby improving the performance and response speed of the system and enhancing user experience.

[0055] Optionally, in this embodiment, the 2m memory block can also be divided into 4k memory pages, and the first 4 pages of the memory page can be used to save the metadata page header (Page Header, referred to as phdr). The advantage of the above method is that the metadata can be directly saved in the header of the memory block, without the need for additional data structures to store metadata information. The above operation can save memory space and facilitate fast access to metadata information. Since the metadata phdr is saved in the header of the memory block, the corresponding small block memory location can be directly located by the serial number in the handle, and the required memory block can be quickly and accurately found, improving the efficiency and speed of memory access. Compared with directly using 4k memory blocks for management, the method of dividing 2m into 4k and saving metadata phdr can simplify memory management. Since the metadata information is directly saved in the header of the memory block, the management is more intuitive and simple, and no additional organization element data is needed, avoiding management complexity. In summary, the method of dividing 2m memory blocks into 4k memory pages and saving metadata phdr in the first 4 pages in the embodiments of the present disclosure can optimize memory management and access efficiency. Through the advantages of simplified management, convenient positioning and saved memory space, the system performance can be improved, the management overhead can be reduced, and the memory access speed can be improved, thereby optimizing the overall running effect of the system.

[0056] In this embodiment, the operating system can be a Linux system, and the kernel can be a Linux kernel. The memory pool is a mechanism in the kernel of the operating system for managing and allocating memory. The operating system kernel is the core part of the operating system, which manages the hardware resources of the operating system and provides core functions such as system scheduling, process management, memory management, and file system.

[0057] Optionally, the capacity of the to-be-allocated memory can be used to represent the size of the to-be-allocated memory block, which can be determined according to the requirements of the program or the operating system, and can be any size in units of bytes, etc. The compressed data is data after compression processing, which is used to reduce storage space and transmission overhead. The compressed data is used to represent the compression result of the memory data exchanged between the physical memory and the virtual memory. These compressed data usually occupy a smaller storage space, which helps to save memory and disk space. The compressed data can be small pieces of data after compression. The data exchanged between the physical memory and the virtual memory can be memory pages, that is, the compressed data can be memory pages after compression.

[0058] Optionally, the physical memory is the actual hardware memory in the operating system of the computer, which is used to store programs and data. The physical memory refers to the memory bar installed on the motherboard of the computer, which is used to store the running programs, operating system, and data. The virtual memory is a memory management technology in the operating system, which can expand the physical memory and can be a disk space or a hard disk space. The disk space is used as an auxiliary storage for storing temporarily unnecessary data and programs. The virtual memory allows data to be exchanged from the physical memory to the disk space to release the physical memory for use by other programs.

[0059] In this embodiment, the to-be-allocated memory in which the compressed data is stored can be obtained, and the capacity of the to-be-allocated memory can be determined.

[0060] Optionally, when it is necessary to allocate a piece of memory from the memory pool, the memory can be used as the to-be-allocated memory, and the size of the to-be-allocated memory can be obtained.

[0061] Optionally, determining the capacity of the to-be-allocated memory can help the system ensure that the size of the allocated memory space is sufficient to store the compressed data. Obtaining the capacity of the to-be-allocated memory is an important step in memory management, which can help the system effectively manage memory resources. By determining the memory capacity, the operating system can allocate memory space of appropriate size according to actual needs, improving the utilization of memory resources. The to-be-allocated memory is used to store compressed data, which is usually used for data exchange between physical memory and virtual memory. By obtaining the memory capacity, it can be ensured that the allocated memory is sufficient to store the exchanged data, so that the system can effectively perform data exchange operations. Determining the capacity of the to-be-allocated memory can avoid allocating too large or too small memory space, thereby avoiding resource waste and improving system efficiency. Reasonably determining the memory capacity can ensure the effective use of memory resources and avoid unnecessary memory waste.

[0062] In summary, obtaining the capacity of the to-be-allocated memory is to ensure that the allocated memory space can meet the needs of storing compressed data, so as to effectively perform data exchange and compression operations and improve the performance and efficiency of the system. By determining the memory capacity, the operating system can better manage memory resources and ensure accurate storage and processing of data.

[0063] In the embodiments of the present disclosure, by compressing data, memory occupation and transmission overhead can be reduced during the memory exchange process. The small piece of memory after compression can be more efficiently stored and transmitted, thereby improving the performance and resource utilization of the operating system. When frequent memory exchange is required, using compressed data can effectively reduce the memory occupation space and reduce the time and overhead of data transmission. Through small memory management, memory exchange and compression operations in a virtualized environment can be better supported. The above-mentioned manner can effectively improve the performance and efficiency of the operating system, while reducing the waste of memory resources and improving the overall resource utilization of the system.

[0064] In step S304, the target metadata matching the capacity is searched in the structure.

[0065] In the technical solution provided by the above step S304 of the present disclosure, the structure can be the total structure of the zbud, and at least includes the metadata of different memories in the memory pool. The metadata can be the overall small memory management metadata, and the metadata is used to describe the data of the data, such as, can be used to describe the characteristics, structure, format, relationship and other data of the data. Metadata is usually used to help the system understand and manage data, provide background information and context of data, so as to more effectively process, store, retrieve and analyze data. The target metadata can be used to represent the metadata of the memory in the memory pool of the structure, which can be adapted to the current capacity, that is, can be the metadata that meets the allocation requirements.

[0066] Optionally, the metadata structure used to manage various chunks in the memory block can be a phdr, which records information of each chunk, including the size, state and pointer to the next segment of the chunk, etc. Through the phdr, the chunks in the memory block can be conveniently managed and operated, and the dynamic allocation and release of memory can be realized.

[0067] Optionally, the metadata structure used to manage various chunks in the memory block can be a phdr, which records information of each chunk, including the size, state and pointer to the next segment of the chunk, etc. Through the phdr, the chunks in the memory block can be conveniently managed and operated, and the dynamic allocation and release of memory can be realized.

[0068] In this embodiment, after determining the capacity of the memory to be allocated, the metadata of different memories stored in the memory pool in the structure body can be searched to find metadata matching the capacity as target metadata.

[0069] Optionally, the capacity of the memory to be allocated can be determined according to the demand or the actual data size. In the metadata of the structure body, various information of the metadata is included, which can include the capacity information of the metadata. By traversing the metadata in the structure body, the metadata matching the capacity of the memory to be allocated can be found as target metadata.

[0070] In the embodiments of the present disclosure, by searching for target metadata matching the capacity, the memory can be more accurately managed and allocated. The target metadata matching the actual demand of the memory capacity can be found, ensuring that the allocated memory meets the demand of the application program and avoiding the situation of memory waste or deficiency. Through the search and positioning of the target metadata, the memory can be quickly and accurately allocated, improving the efficiency and accuracy of memory management. According to the actual demand, the target metadata can be searched to avoid excessive allocation of memory, save system resources, and improve the resource utilization rate of the system. By dynamically searching for target metadata matching the capacity, dynamic adjustment of memory allocation can be supported, flexible allocation can be performed according to the actual demand, and the adaptability and flexibility of the system can be improved.

[0071] In summary, by searching for target metadata matching the capacity, precise, efficient and resource-saving memory management can be realized, and the technical effects of improving the performance and resource utilization efficiency of the operating system can be achieved. The above technical effects can help to optimize the memory management process and improve the overall operation efficiency and stability of the operating system.

[0072] In step S306, based on the target metadata, the position information of the memory to be allocated is determined.

[0073] In the technical solution provided in step S306 of this disclosure, the location information can be used to represent the position of the memory to be allocated in the memory pool corresponding to the structure. It can be the position of the memory to be allocated in the zbud, for example, it can be the allocation position block (chunk, abbreviated as chk) sequence number. This allocation position chk sequence number refers to the sequence number of the allocation position obtained after allocating a small segment of memory from the zbud pool according to demand during memory allocation. This sequence number records from which position the memory block begins to be allocated and used. In specific implementations, the allocation position chk sequence number may be an offset relative to the starting position of the memory block, or it may be an identifier that can be used to uniquely identify this allocation position. This sequence number can be used to locate the allocated memory block for subsequent operations and management.

[0074] In this embodiment, after finding the target metadata that matches the capacity in the structure, the location information of the memory to be allocated can be determined based on the target metadata.

[0075] Optionally, target metadata is obtained from the structure's metadata. This metadata records information about the memory to be allocated for the compressed data, including its capacity and status. The size of the memory to be allocated is determined using the capacity information recorded in the target metadata. Based on other information in the target metadata, such as the starting position and offset of the memory block, combined with the capacity of the memory to be allocated, the location information of the memory to be allocated within the structure can be determined. Based on the determined location information, the memory block corresponding to the compressed data is allocated from the memory pool. This achieves effective management and allocation of the compressed data.

[0076] The above methods allow for the determination of memory allocation location information through target metadata, ensuring efficient memory allocation and management. These methods improve memory utilization efficiency, reduce memory usage and transmission overhead, thereby enhancing operating system performance and resource utilization. Through structured memory management, effective management and exchange of compressed data are achieved, resolving the technical problem of inefficient memory allocation and supporting memory swapping and compression operations in virtualization environments. These methods contribute to improved system performance and efficiency while ensuring the accuracy and effectiveness of memory management.

[0077] Step S308: Based on the location information, allocate memory from the memory pool corresponding to the compressed data.

[0078] In the technical solution provided by step S308 of this disclosure, after determining the location information of the memory to be allocated based on the target metadata, memory corresponding to the compressed data can be allocated from the memory pool based on the location information.

[0079] Optionally, according to the position information of the compressed data and the size of the compressed data, the position information of the memory block to be allocated in the structure can be determined, wherein the position information of the compressed data can include the starting position, offset, etc. According to the size of the compressed data, the size of the memory block to be allocated is determined. According to the determined position information and memory size, the memory block corresponding to the compressed data is allocated from the memory pool. The memory allocation operation can be performed using a memory allocation function or a custom memory management method. The compressed data is stored in the allocated memory block, ensuring correct storage and management of the data. The position information of the allocated memory block is recorded for subsequent operation and management.

[0080] Through the above method, the memory corresponding to the compressed data can be allocated from the memory pool according to the position information. This process can ensure effective allocation and management of memory, ensuring correct storage and use of data. Through reasonable memory allocation, the performance and resource utilization efficiency of the system can be improved, while supporting effective management and operation of compressed data.

[0081] Optionally, once the target metadata matching the capacity is found, the position information of the target metadata in the structure needs to be determined. This can include the offset, storage position, etc. of the metadata in the structure. According to the determined position information of the target metadata, the memory corresponding to the compressed data can be allocated in the structure. In this way, effective management and allocation of compressed data are achieved. Through the above process, the target metadata matching the capacity can be effectively found in the structure, and memory allocation is performed, achieving effective management and storage of compressed data. The above memory management method can improve the performance and efficiency of the operating system, solving the technical problem of memory allocation, while supporting memory exchange and compression operation in a virtualized environment.

[0082] Through the above steps S302 to S308 of the present disclosure, in the memory exchange process, the to-be-allocated memory in which the compressed data of the data used for exchange between the physical memory and the virtual memory is stored can be obtained, and the capacity of the to-be-allocated memory is determined. The metadata matching the above capacity can be queried as target metadata in the metadata in the structure. The position information of the to-be-allocated memory in the memory pool corresponding to the structure can be determined according to the target metadata, and the memory corresponding to the compressed data is allocated from the memory pool according to the position information, so as to realize memory allocation. In this embodiment, the compressed memory is used to reduce memory occupation and transmission overhead. In the memory exchange process, the small block of memory after compression can be more efficiently stored and transmitted, so as to improve the performance and resource utilization of the operating system, and the small block of memory management can better support the memory exchange and compression operation in the virtualization environment. Through the above structured memory management manner, the effective storage and exchange of the compressed data between the physical memory and the virtual memory are ensured. Through the processes of searching for the target metadata, determining the position information, and allocating the memory, the effective management and allocation of the compressed data are realized, the performance and efficiency of the operating system are improved, and the technical effect that the memory can be effectively allocated is realized, and the technical problem that the memory cannot be effectively allocated is solved.

[0083] The above method of this embodiment will be further introduced below.

[0084] As an optional implementation, in step S304, searching for the target metadata matching the capacity in the structure includes: converting the capacity into a segment number, where the segment number is used to represent the number of memory units corresponding to the capacity, and the memory unit is used to represent the smallest memory unit allowed to be allocated in the memory; searching for metadata satisfying the segment number in the structure; and determining the searched metadata as the target metadata matching the capacity.

[0085] In this embodiment, in the process of finding the target metadata matching the capacity in the structure, the capacity can be converted into the number of segments, the metadata meeting the number of segments is found in the structure, and the metadata is determined as the target metadata matching the capacity, wherein the number of segments can be used to represent the number of memory units corresponding to the capacity, which can be the number of small segments (Number of Chunks, abbreviated as nr_chk). The nr_chk refers to the number of small segments required when a small segment of memory is allocated from the zbud pool according to the demand, and the required memory size is converted into the number of small segments nr_chk according to the size of the required memory and the granularity of the small segment (for example, 64 bytes). The nr_chk represents the number of small segments required, and ensures that the size of the allocated memory can meet the demand, which can be greater than or equal to the size, that is, in memory management, the nr_chk is used to represent the number of small segments converted from the required memory size, so as to perform memory allocation and management. In this way, the memory can be more effectively managed and allocated, and the effective use and reasonable allocation of memory are ensured. The memory unit can also be referred to as the smallest allocation unit.

[0086] Optionally, the size of the capacity desired to be allocated from the memory pool, that is, the size of the memory, is determined. According to the granularity of the small segment (for example, 64 bytes), the size of the capacity is converted into the number of small segments nr_chk. This conversion process is obtained by dividing the size of the capacity by the granularity of the small segment (64 bytes), and ensures that the number of segments after conversion is greater than or equal to the capacity of the required memory. That is, if the memory with a capacity size of size needs to be allocated from the memory pool, the number of small segments as the smallest allocation unit can be determined according to the granularity of 64 bytes. The number of small segments can be obtained by dividing size by 64 bytes. If size is not an integer multiple of 64, an additional small segment can be added to meet the actual memory demand. The number of segments nr_chk after conversion is determined, which represents the number of small segments corresponding to the capacity of the required memory, and is used for subsequent finding of the target metadata matching the capacity in the structure. According to the number of segments nr_chk after conversion, the metadata matching the number of segments is found in the structure, which records the information of the memory block, including the size, the state, etc. After the metadata meeting the number of segments is found, it is determined as the target metadata matching the capacity, which indicates that this metadata can be used to allocate the capacity of the required memory.

[0087] Through the above process, the capacity of the required memory can be converted into the corresponding number of segments, and then the metadata matching the number of segments is found in the structure, and finally the target metadata for allocation is determined. The above conversion process can better manage and allocate memory, and ensure the accuracy and effectiveness of memory allocation.

[0088] In the embodiments of the present disclosure, when a small piece of memory needs to be allocated from the zbud pool, the required memory size size and the granularity of the small piece (64 bytes) are converted into the required number of small pieces nr_chk, and nr_chk is ensured to be greater than or equal to size. This process is mainly to calculate the actual number of small pieces nr_chk required for allocation according to the actual required memory size size and the granularity of system memory management (64 bytes). If the required memory size size is an integer multiple of the small piece, then nr_chk is the result of size divided by 64 bytes; if it is not an integer multiple, then it needs to be rounded up to ensure that the number of allocated small pieces can meet the required memory size. This conversion process is to ensure that memory allocation is performed according to the granularity of system memory management, and the number of small pieces required can be accurately calculated, so that subsequent memory allocation and management operations can be processed according to the granularity. In this way, the accuracy and efficiency of memory allocation can be ensured.

[0089] Optionally, the process of finding metadata that meets the number of small pieces nr_chk from the structure can be implemented by the following steps: first, all metadata recorded in the structure can be traversed, which may include information of various memory blocks, including size, state, allocation, etc. For each metadata, check the number of small pieces recorded, i.e. the number of small pieces that the metadata can accommodate. This number should be greater than or equal to nr_chk to meet the required memory size for allocation. When the number of small pieces of a metadata meets nr_chk, the metadata that meets the condition is found, which can be determined as the target metadata for allocating the required memory. The metadata that meets the number of small pieces nr_chk is returned as the target metadata for subsequent memory allocation operations. Through the above method, the metadata that meets the number of small pieces nr_chk can be effectively found in the structure, ensuring that the allocated memory size matches the metadata recorded in the structure, and accurate memory allocation and management can be achieved. The above method can improve the utilization efficiency of memory and ensure the accuracy and effectiveness of memory management.

[0090] Optionally, the zbud memory pool can include a memory pool list table group (mp_list), which can be a data structure for managing memory blocks and related information in the memory pool. The mp_list can include a free memory block list table and an allocated memory block list table, thereby more efficiently managing memory blocks in the memory pool, effectively allocating and releasing memory, and improving memory utilization and system performance. It should be noted that the information included in the mp_list table group described above is only for illustration and is not specifically limited. Each element (i.e., each mp) in the queue of the mp_list table group is organized and sorted according to the size of its largest free memory block. This organization can enable the system to more effectively manage and utilize memory pages, so as to select the most suitable memory page to allocate memory blocks in subsequent memory allocation operations. The phdr metadata is used to save the mp that has been partially allocated. In a lightweight virtualization architecture, the zbud memory pool is used to manage and allocate small memory blocks. The mp_list table group saves the metadata of the memory blocks that have been partially allocated, which records the allocation, status, and location information of the memory blocks. Optionally, each node in the mp_list table group corresponds to a phdr metadata structure of an mp that has been partially allocated. The phdr records the size, allocation status, location information, and other related information of the memory block. Through the mp_list table group, the system can track the allocated memory blocks and quickly find the allocated memory blocks that meet the requirements, so as to further allocate and manage memory. Through the maintenance of the mp_list table group, the memory allocation can be efficiently managed, and the effective utilization and management of memory can be ensured.

[0091] Optionally, in the process of finding metadata that meets the segment number, the operating system can find whether there is a phdr that has been partially allocated according to the nr_chk requirement in the mp_list table group of the zbud. When traversing the mp_list table group, the operating system will check each phdr metadata structure one by one to check whether the allocated memory block recorded in the phdr metadata structure meets the requirement of the nr_chk. If an already partially allocated phdr is found, whose small segment number of the allocated memory block meets the requirement of the nr_chk, then this phdr is the metadata that meets the segment number.

[0092] Optionally, in the process of determining the target metadata matching the capacity, if a phdr satisfying the nr_chk requirement is found in the above method, the operating system can obtain this phdr satisfying the allocation requirement and dequeue it from the zbud corresponding list, indicating that this phdr will be used for allocating the required memory. Then, according to the maximum index (max_idx) position, the operating system sets the subsequent nr_chk chunks to the allocation state, that is, marks these memory blocks as allocated, and records the allocation position chk number. This phdr satisfying the allocation requirement is the target metadata matching the capacity, because it records the information of the allocated memory blocks and satisfies the required memory size. Therefore, the phdr is determined as the target metadata for allocating the required memory, where max_idx can be the serial number of the starting position of the largest continuous free segment, which records the index of the starting position of the largest continuous free segment, used to determine the position of the largest continuous free segment in the available memory. The starting position of the continuous free segment in the memory is marked to enable the operating system to more efficiently allocate and manage memory.

[0093] Optionally, by recording the starting position index of the largest continuous free segment, the operating system can accurately determine the starting position for allocation in the memory. According to the starting position index of the largest continuous free segment, a large enough continuous free memory block can be quickly found, thereby optimizing the efficiency of memory allocation. "max_idx" can be an important parameter in memory management, helping the operating system to better organize, allocate and release memory, and improving the overall performance and stability of the system.

[0094] Through the above method, the operating system can find and determine the metadata satisfying the required segment number in the mp_list list group of zbud, and then use it as the target metadata matching the required capacity for further memory allocation operation. The above process can effectively manage memory allocation and ensure the accuracy and effectiveness of memory allocation.

[0095] As an optional implementation, in step S306, based on the target metadata, the position information of the memory to be allocated is determined, including: based on the target metadata, the state of the memory units of the segment number in the memory is determined to be in the allocation state; and based on the memory units in the allocation state, the position information of the memory to be allocated is determined.

[0096] In this embodiment, in the process of determining the location information of the to-be-allocated memory based on the target metadata, the state of the memory units of the segment number of memory can be determined as the allocation state based on the target metadata. And the location information of the to-be-allocated memory can be determined according to the memory units in the allocation state, wherein the memory units of the segment number can be nr_chk memory chunks. The allocation state refers to the current use state of the memory unit, which indicates whether the memory unit has been allocated to a certain program or task for use. The allocation state can be an allocated state. Corresponding to the allocation state is the idle state. The memory unit in the allocated state means that the memory unit has been allocated to a certain program or task for use, for storing data or program code. In the allocated state, the memory unit is marked as occupied and cannot be allocated to other programs again.

[0097] Optionally, when the operating system obtains the target metadata that meets the allocation requirement, the target metadata can be dequeued from the corresponding linked list in the memory pool. And the state of the segment number of memory units corresponding to the target metadata can be determined as the allocation state. Once the segment number of memory units is set to the allocation state, the operating system records the location information of the to-be-allocated memory.

[0098] Optionally, in the process of determining the allocation state of the memory unit, after the operating system obtains a phdr that meets the allocation requirement, the phdr can be dequeued from the zbud corresponding linked list. According to the max_idx position of the phdr, the operating system sets the subsequent nr_chk chunks to the allocation state. This means that these memory units will be marked as allocated state and can no longer be used for other allocations, wherein the max_idx position refers to the maximum free index position in the allocated memory block. In memory management, the max_idx position is usually used to record the index position of the last memory unit in the allocated memory block, so as to determine the starting position of the next memory allocation. The max_idx position is an important indicator that can help the system effectively manage the allocation and release of memory.

[0099] Optionally, in the process of determining the location information of the to-be-allocated memory, once the nr_chk memory units are set to the allocation state, the operating system records the allocation position chk sequence number. This sequence number indicates from which position the consecutive nr_chk memory units are allocated. Based on the memory units in the allocated state, the system can determine the location information of the to-be-allocated memory according to the allocation position chk sequence number. In this way, the operating system can accurately locate the allocated memory block and ensure the effective management and use of memory.

[0100] By the above method, the operating system can determine the memory unit state of the required segment number as an allocation state based on the target metadata, and determine the location information of the to-be-allocated memory according to the memory unit in the allocation state. The above process can realize effective allocation and management of memory, and ensure the accuracy and effectiveness of memory allocation.

[0101] As an optional implementation, based on the memory unit in the allocation state, the location information of the to-be-allocated memory is determined, including: determining the position sequence number of the memory unit in the allocation state; determining the virtual address corresponding to the position sequence number of the memory unit; and determining the virtual address as the location information of the to-be-allocated memory.

[0102] In this embodiment, in the process of determining the location information of the to-be-allocated memory based on the memory unit in the allocation state, the position sequence number of the memory unit in the allocation state can be determined, and the virtual address corresponding to the position sequence number can be determined as the location information of the to-be-allocated memory. The position sequence number can be an allocation position chk sequence number. The virtual address can be a kernel virtual address (kva). The kernel virtual address refers to the address used by the operating system kernel in the virtual memory space. In the operating system, virtual memory allows the operating system to allocate a block of continuous virtual memory space to each application program, without having to consider the actual allocation of physical memory. In this way, memory can be better managed, and the utilization of memory and the stability of the operating system can be improved.

[0103] Optionally, in the process of determining the position sequence number of the memory unit in the allocation state, the operating system can obtain target metadata satisfying the allocation requirement from the zbud corresponding linked list, and can set the memory units of the subsequent segment number to be in the allocation state according to the max_idx position of the target metadata. The position sequence number can be determined according to the max_idx position. In the process of determining the virtual address, the operating system can return the corresponding kernel virtual address according to the position sequence number.

[0104] Optionally, in the process of determining the allocation position chk sequence number, the operating system can obtain a phdr satisfying the allocation requirement from the zbud corresponding linked list, and then set the subsequent nr_chk chunks to be in the allocation state according to the max_idx position thereof. The allocation position chk sequence number is usually determined according to the index position or offset of the memory block, for example, the sequence number of the continuous nr_chk memory units starting from the max_idx position. This allocation position chk sequence number records the position from which the continuous nr_chk memory units in the allocated memory block are allocated, for subsequent memory access and management.

[0105] Optionally, in the process of determining the virtual address, the system can return the corresponding kernel-mode virtual address according to the allocated chk sequence number. This virtual address is an address used by the operating system to access memory, usually a virtual memory address, used to access data in physical memory. To determine the virtual address corresponding to the position sequence number of the memory unit, the operating system can calculate it according to the starting address of the memory unit, the offset, and the address mapping mechanism of the operating system. This ensures that the system can quickly locate the corresponding memory unit according to the allocated position chk sequence number, and perform read, write and management operations on the data.

[0106] Through the above process, the operating system can effectively determine the allocation position chk sequence number of the memory unit in the allocation state, and determine the virtual address corresponding to the memory unit according to the position sequence number, thereby realizing accurate management and operation of the memory. The above process is beneficial to the allocation and management of memory, and ensures the performance and stability of the operating system.

[0107] As an optional implementation, based on the memory unit in the allocation state, the position information of the to-be-allocated memory is determined, including: determining the association information of the memory unit in the allocation state, wherein the association information is used to represent information associated with the attribute of the memory unit; encoding the association information to obtain an encoding result; and determining the position information of the to-be-allocated memory in the memory pool based on the encoding result.

[0108] In this embodiment, in the process of determining the position information of the to-be-allocated memory based on the memory unit in the allocation state, the association information of the memory unit in the allocation state can be determined, the encoding result is obtained by encoding the association information, and the position information of the to-be-allocated memory is determined from the memory pool by using the encoding result, wherein the association information can be used to represent information associated with the attribute information of the memory unit, and the attribute of the memory unit can be the sequence number, the number and the size of the memory unit, etc. This is only an example and is not limited specifically. Based on the above attributes, the corresponding association information can include the ms, mp and chunk sequence number of the chunk, and can also include the difference (difference, abbreviated as diff) between the nr_chk number, the nr_chk size and the allocation size size. nr_chk refers to the number of small segments converted from the required memory size in the zbud pool. The nr_chk size refers to the memory size represented by the nr_chk number. Specifically, the nr_chk size depends on the required memory size and the granularity of the small segment. By converting the required memory size into the number of small segments nr_chk, and determining the size of each small segment according to the granularity of the small segment, the size of nr_chk can be calculated.

[0109] Optionally, the encoding result can be an encoding handler for processing the operation of encoding the specific data, usually including converting the data into a specific format or encoding mode for transmission, storage or processing in the system. Through the encoding handler, the encoding and decoding of the data can be realized to ensure the safe transmission and accurate processing of the data.

[0110] Optionally, in the process of determining the association information of the memory unit in the allocated state, the position information of the allocated memory unit and other attributes related thereto can be determined according to the position serial number of the memory unit in the allocated state to obtain the association information.

[0111] Optionally, after obtaining the association information, the association information can be encoded to obtain an encoding result, so that the position of the allocated memory block can be quickly located subsequently. Through the encoding result, the operating system can analyze the encoding result through a specific decoding mode to obtain the association information included in the encoding information to determine the position information of the memory to be allocated.

[0112] Optionally, in the process of determining the association information of the memory unit in the allocated state, according to the allocated chk serial number, the operating system can determine the position information of the allocated memory block and information related thereto such as ms, mp and chunk serial number. The association information includes the position of the allocated memory block, the memory block to which it belongs, the memory page and the memory segment information, and the size and number of the allocated memory block.

[0113] Optionally, in the process of encoding the association information to obtain the encoding result, the association information can be encoded to form an encoding handler so that the position of the allocated memory block can be quickly located in subsequent operations. That is, through the encoding handler, multiple association information can be combined together to form an identifier of the memory block, thereby realizing the quick positioning of the position of the allocated memory block. For example, the information such as ms, mp, chunk serial number, nr_chk number, nr_chk size and the difference diff between the allocation size size can be combined into an encoding handler. The encoding handler can be a data structure containing the above information, or a specific format encoding string for identifying the related information of the allocated memory block.

[0114] Optionally, the information such as ms, mp, chunk number, nr_chk number, nr_chk size, and the difference diff between the allocation size size is combined into an encoding handler. The above-mentioned encoding handler can be a structure, a data object containing all information, or an encoding string in a specific format, which is only an example and is not limited. By combining multiple associated information into a handler, a unique identifier can be generated to identify the location of the allocated memory block. This unique identifier can help the system accurately and quickly locate and identify the specific memory block. In subsequent operations, the relevant information of the allocated memory block, including the memory pool, memory block index, size difference, etc. can be obtained by parsing the encoding handler, so as to quickly locate the position of the allocated memory block. Through the encoding handler, it is not necessary to find or traverse the memory block one by one, but the target memory block can be quickly located according to the unique identifier, which improves the operation efficiency and response speed. By encoding the associated information through the encoding handler, it can ensure that the relevant information is correctly associated and recorded, avoiding information loss or confusion, and improving data consistency and reliability. By encoding the associated information into the handler, the location of the allocated memory block can be more effectively managed and located, improving the efficiency and accuracy of memory management. This technical feature can make the system better utilize memory resources and improve system performance and response ability.

[0115] Optionally, in the process of determining the location information of the to-be-allocated memory, the operating system can obtain the associated information contained in the encoding information by decoding the encoding result through a specific decoding manner through the encoding handler. According to the information obtained by decoding, the operating system can determine the location information of the to-be-allocated memory, including the location, size and number of the allocated memory block. In this way, the allocated memory block can be quickly located and accessed in subsequent operations, ensuring effective management and use of memory.

[0116] Optionally, in the process of reverse parsing the encoding result, the operating system can parse the encoding handler through a specific decoding method to obtain the associated information contained in the encoding information. Through this process, the location information of the memory to be allocated can be determined, including the location, size, and number of allocated memory blocks, etc. The encoding handler contains multiple associated information, such as ms, mp, chunk sequence number, nr_chk number, nr_chk size, and the difference diff between the allocation size size, etc. These information are encoded to form a unique identifier. By parsing the encoding handler through a specific decoding method, the encoding information is restored to the original associated information according to the predetermined decoding rules. Through the parsed information, the location, size, and number of allocated memory blocks can be obtained. These information can help determine the location information of the memory to be allocated. According to the associated information obtained by parsing, the location information of the memory to be allocated can be determined in the structure of memory management, including the location, size, and number of allocated memory blocks. In this way, it can be ensured that the system can accurately manage and locate the allocated memory blocks. Through this reverse parsing process, the relevant information of the allocated memory blocks can be conveniently recorded and managed, and these memory blocks can be quickly located and accessed. This helps to improve the efficiency and accuracy of memory management.

[0117] In the embodiments of the present disclosure, by reverse parsing the encoding result, the associated information contained in the encoding information can be fully utilized to determine the location information of the memory to be allocated, and to ensure the effective management and use of memory. This encoding and decoding process improves the management ability of the system for memory resources, and enhances the performance and reliability of the system.

[0118] It should be noted that by encoding the associated information of the allocated memory blocks, the relevant information of the allocated memory blocks can be conveniently recorded and managed, and these memory blocks can be effectively located and operated, and the above encoding and decoding process helps the efficiency and accuracy of memory management.

[0119] As an optional implementation, step S304, the method further comprises: in response to not finding the metadata satisfying the segment number in the structure, finding the memory block in the memory page in the idle state from the linked list of the structure, wherein different nodes of the linked list are used to represent different memory blocks; in response to finding the memory block in the memory page in the idle state, determining the target metadata based on the metadata corresponding to the memory page in the idle state in the structure.

[0120] In this embodiment, in the process of finding target metadata matching the capacity in the structure, it can be determined whether metadata satisfying the number of segments is found in the structure. If not, a memory block in a memory page in an idle state can be found from the linked list of the structure. When a memory block in a memory page in an idle state is found, the target metadata can be determined based on the metadata corresponding to the memory page in an idle state in the structure. Different nodes of the linked list can be used to represent different memory blocks. The zbud is a total structure for managing small block memory, which includes multiple fields to record and manage the related information of the memory pool. The included fields can include: the number of ms obtained by the small block memory pool, which records the number of memory blocks in the small block memory pool, and is used to track the size and usage of the memory pool; the linked list of full ms, that is, the full buddied list (Memory Segment buddied, abbreviated as ms_buddied), which stores the linked list of memory blocks that have been completely allocated, and is used to manage the memory blocks that have been completely allocated; the ms linked list of half full, that is, the unbuddied list (Memory Segment Unbuddied List, abbreviated as ms_unbuddied), which is linked in an array linked list according to the maximum free number (1-63).

[0121] This means that in memory management, for half-full memory blocks, array linked lists can be used to manage these memory blocks. The array linked list is an array structure composed of multiple linked lists, where each element is a linked list header, and the linked list header points to a linked list. Each linked list in the array linked list is arranged in ascending order according to the number of free memory blocks. In this way, the corresponding linked list can be directly located according to the size of the free number, thereby more efficiently managing the half-full memory blocks. By organizing half-full memory blocks into array linked lists according to the free number, these memory blocks can be better managed, improving the efficiency and performance of memory management. The above method can intuitively show the free status of different memory blocks and quickly locate the required memory blocks, thereby optimizing memory management operations. The lock protection of the ms linked list (ms_list_lock) is used to protect the locks of the ms_buddied and ms_unbuddied linked lists, ensuring that the access and operation of the linked lists are thread-safe; the mp linked list array mp_list linked list group contains memory block linked list arrays of different free numbers, from 1 to 63 free memory blocks, that is, the mp_list linked list group (free number from 1-63), which is used to organize and manage free memory blocks; the lock protection of the mp linked list (mp_list linked list group_lock) is used to protect the locks of the mp_list linked list group array, ensuring that the access and operation of different free number memory block linked lists are thread-safe.

[0122] It should be noted that the above fields are only for illustration and are not specifically limited here.

[0123] In the embodiments of the present disclosure, by recording the number of memory block acquisitions and the memory block linked list of different free quantities in the small block memory pool, the zbud total structure body can effectively manage the allocation and release of memory blocks. By maintaining the full and half full memory block linked list, zbud can track and manage the usage of memory blocks. By using the lock protection mechanism, it is ensured that the access and operation of the memory block linked list are thread-safe, avoiding data competition and errors caused by concurrent access. In summary, the zbud total structure body is a metadata for managing small block memory, and by recording and organizing different types of memory block linked lists and using the lock protection mechanism, memory can be effectively managed and allocated, improving the performance and stability of the system.

[0124] Optionally, the ms_unbuddied linked list is a linked list in the zbud memory pool, used to save the metadata structure of the ms with free mp. In the lightweight virtualization architecture, the ms_unbuddied linked list is used to record the information of the memory block with free memory pages, so as to be allocated and managed subsequently. The memory unit in the free state indicates that the memory unit is currently not used and can be allocated to programs or tasks by the system. The memory unit in the free state can be reallocated to new programs or tasks for storing data or program code. The memory unit can be a small memory segment, that is, a memory small segment chunk.

[0125] Optionally, according to the number of small segments nr_chk calculated previously, it can be found from the mp_list linked list group of zbud whether there is a partially allocated chunk header phdr, and the memory small block meets the requirement of nr_chk. In the above process, the mp_list linked list group of zbud can be checked to find whether there is a partially allocated phdr of mp that meets the requirement of nr_chk. If a partially allocated phdr that meets the requirement of nr_chk is found in the mp_list linked list group, that is, the memory small block can meet the requirement of allocating nr_chk small segments, the found phdr is directly returned. If there is no partially allocated phdr that meets the requirement of nr_chk in the mp_list linked list group, it indicates that no metadata that meets the segment quantity requirement is found in the structure body.

[0126] The purpose of the above process is to try to find whether there is a memory block with the required number of continuous small segments from the partially allocated memory small block, so as to avoid allocating a new memory block and improve the efficiency of memory allocation. If a partially allocated memory small block that meets the requirement is found, the memory small block can be directly used for allocation, otherwise subsequent processing needs to be continued.

[0127] Optionally, if a phdr that meets the nr_chk requirement is not found in the mp_list linked list group, further searching is needed. Check if there is a free ms (memory block) in the ms_unbuddied linked list of zbud. If there is a free ms, return the ms, indicating that an ms that can be split is found. If a free ms is not found in the ms_unbuddied linked list, allocate a new mp from the ms of the upper layer to split. Try to find an ms with a free mp in the ms_unbuddied linked list. If an ms that meets the condition is found, return the ms (shdr), indicating that an ms that can be split is found. If a phdr that meets the segment number is found, corresponding operations can be performed.

[0128] Through the above method, it can be determined whether the metadata that meets the segment number is found in the structure. If not, the memory block including the memory page in the idle state can be found from the ms_unbuddied.

[0129] Optionally, in the memory block ms, if all the memory pages mp are allocated, the memory block ms will be mounted in the full ms (Memory Segment buddied, referred to as ms_buddied) linked list.

[0130] The above management method can effectively distinguish between completely allocated and partially allocated memory blocks, facilitating the management and allocation of memory blocks by the system. The full ms linked list is used to store memory blocks that have been completely allocated, and the half full ms linked list is used to store memory blocks that have been partially allocated, thereby realizing the management and optimization of memory blocks in different states.

[0131] According to the allocation of the memory pages mp in the memory block ms, the memory block ms is mounted in the full ms linked list or the half full ms linked list. The above management method helps to classify and manage the state of the memory block, improving the efficiency and flexibility of memory management.

[0132] As an optional implementation, in response to finding a memory block in a memory page in an idle state, determining the target metadata based on the metadata corresponding to the memory page in an idle state in the structure includes: in response to finding a memory block in a memory page in an idle state, determining a first target memory page in an idle state based on the bitmap of the metadata corresponding to the memory page in an idle state in the structure; determining the state of the first target memory page as an allocated state; and determining the target metadata based on the first target memory page in an allocated state.

[0133] In this embodiment, in the process of finding the memory block in the memory page in the idle state and determining the target metadata based on the corresponding metadata in the structure of the memory page in the idle state, the first target memory page in the idle state can be determined based on the bitmap of the corresponding metadata of the memory page in the structure. The state of the first target memory page can be determined as the allocation state, and the first target memory page in the allocation state can be determined as the target metadata. The first target memory page can be the memory page in the idle state, that is, the idle mp. The bitmap of the metadata can be the bitmap of the shdr. The shdr bitmap is a data structure used to represent the allocation of the memory block managed by an shdr. In memory management, the shdr bitmap is usually used to record the allocation state of each memory block to manage and track the allocation and release of memory. The shdr bitmap is usually a binary bit array, and each bit corresponds to a memory block. Each bit can have two states: 0 or 1. 0 is used to indicate that the corresponding memory block is idle and has not been allocated to any data or structure; 1 is used to indicate that the corresponding memory block has been allocated and is used to store data or structure. Through the operation of the shdr bitmap, dynamic allocation and release of memory blocks can be realized. When memory needs to be allocated, the system checks the bitmap to find the idle memory block; when memory is released, the system sets the corresponding bitmap position to 0, indicating that the memory block is idle and available.

[0134] In the memory management process, the shdr bitmap plays an important role in helping the system efficiently manage memory resources and avoid repeated allocation problems. Through the bitmap method, the system can quickly query the idle memory block to improve the efficiency and performance of memory allocation.

[0135] Optionally, after finding the shdr that meets the allocation requirements, the memory page in the idle state can be determined according to the bitmap of the shdr.

[0136] Optionally, in the process of determining the free mp based on the bitmap of the corresponding shdr in the memory page-based structure, the bitmap information can be obtained from the shdr found in the above method that meets the allocation requirements. The bitmap is a data structure used to represent the allocation status of memory blocks, with each bit corresponding to a memory block. A bit value of 0 indicates that the memory block is free, and a bit value of 1 indicates that the memory block has been allocated. The bitmap of the shdr is traversed, and the value of each bit is checked one by one from the beginning. The free memory page corresponds to the position with a value of 0 in the bitmap, indicating that the memory page has not been allocated. When a position with a value of 0 in the bitmap is found, a free memory page is found. The starting address and size of the corresponding memory block can be calculated based on the position. The bit corresponding to the free memory page is set to 1, indicating that the memory page is marked as allocated. According to the current state of the ms, the free memory page is allocated to the required allocation operation, such as chunk allocation. According to the current state of the ms, the updated shdr is re-linked to the full or half-full queue in the zbud, ensuring the consistency of the memory management system.

[0137] Through the above method, after finding the shdr that meets the allocation requirements, the free memory page can be determined based on the bitmap of the shdr, and the corresponding allocation operation can be performed. This can effectively manage and utilize memory resources, ensuring the correctness and efficiency of memory allocation.

[0138] Optionally, in the process of determining the free memory page as an allocated state, an idle memory page is found through the bitmap of the shdr, i.e. the position corresponding to the bit value of 0 in the bitmap, indicating that the memory page has not been allocated. Then, the corresponding bit is set to 1, indicating that the memory page is marked as allocated. This step usually involves bit operations on the bitmap, changing the bit value of the corresponding position from 0 to 1. Ensure that the updated bitmap information corresponds to the allocation status of the memory page, so that subsequent memory allocation and management operations can correctly identify and utilize the allocated memory page. According to the current memory management situation, the memory page in the allocated state is allocated to the required operation or data structure, ensuring that the memory resources are effectively utilized. According to the current state of the ms, the shdr is updated and re-linked to the corresponding full or half-full queue in the zbud, to ensure the consistency and correctness of the memory management system.

[0139] Through the above method, the state of the free memory page can be determined as an allocated state. This can ensure that memory resources are correctly allocated and managed, avoiding memory leaks and repeated allocation problems, while improving the efficiency and performance of memory allocation.

[0140] Optionally, in the process of determining the target metadata based on the memory page in the allocated state, the memory page can be determined to have been allocated to a certain data structure or operation according to the allocation state of the memory page. The shdr to which the memory page belongs will generally contain metadata information about the memory page. According to the bitmap information of the shdr, the position and index of the memory page in the shdr can be determined. The position information of the memory page in the shdr can be determined through the bitmap, so as to find the corresponding metadata. According to the position and index of the memory page, the corresponding metadata structure in the shdr can be accessed. The metadata structure generally contains relevant information about the memory page, such as the information of the segment to which the memory page belongs, the allocation state, the size, etc. By accessing the metadata structure corresponding to the memory page, detailed information and attributes about the memory page can be further obtained. According to the obtained metadata information, the target metadata, i.e., the metadata required by the data structure or operation to which the memory page belongs, can be determined. Finally, according to the information and attributes of the target metadata, corresponding operations or processing can be performed, such as reading, writing, updating, etc.

[0141] Through the above method, the target metadata can be determined based on the memory page in the allocated state, so as to realize the access and management of data in the memory page. In this way, the memory resources can be correctly allocated and utilized, while ensuring the integrity and consistency of the data.

[0142] As an optional implementation, determining the target metadata based on the first target memory page in the allocated state includes initializing the first target memory page in the allocated state, and determining the metadata corresponding to the initialized first target memory page as the target metadata.

[0143] In this embodiment, in the process of determining the target metadata based on the first target memory page in the allocated state, the first target memory page in the allocated state can be initialized, and the metadata corresponding to the initialized first target memory page can be determined as the target metadata.

[0144] Optionally, the process of determining the target metadata based on the memory page in the initial allocation state includes initializing the memory page in the allocated state and determining the metadata corresponding to the initialized memory page as the target metadata.

[0145] Optionally, the process of initializing the initially allocated mp generally includes setting the initial state, allocating the metadata structure required by the memory page, and adding it to the corresponding linked list.

[0146] Optionally, in the process of setting the initial state, the state of the memory page is initialized, including the number of free blocks, index, and other information. Set the maximum free number (max_free) to 64, indicating that the maximum number of free blocks available in the memory page is 64. Initialize max_idx to 0, indicating that no free block is used in the initial state. Initialize the maximum free number max_free to 64, indicating that the maximum number of free blocks available in the memory page is 64. Initialize max_idx to 0, indicating that no free block is used in the initial state. In the process of allocating the metadata structure required for the memory page, according to the requirements and management mode of the memory page, the corresponding metadata structure is allocated for the memory page, such as phdr. Initialize the metadata structure and fill in the necessary information, such as the starting address, size, state, and other information of the memory page. In the process of adding the metadata structure of the memory page to the corresponding linked list, the metadata structure corresponding to the memory page (such as the segment header phdr) is added to the corresponding linked list for subsequent management and operation. Ensure that the metadata structure of the memory page is correctly inserted into the linked list, so that the operating system can quickly access and process the memory page when needed. In the process of checking and verifying the initialization result, ensure that the state and metadata structure of the memory page are correctly initialized, including the correct setting of parameters such as max_free and max_idx. Verify whether the metadata structure of the memory page is successfully added to the corresponding linked list to ensure that the memory page can be correctly managed and utilized.

[0147] Through the above method, the initially allocated memory page can be initialized to ensure that the memory resources are correctly allocated and managed, and the necessary metadata structure and information are provided for subsequent operation. This can ensure the effectiveness and stability of the memory management system.

[0148] Optionally, in the process of adding the corresponding phdr to the corresponding zbud free list, according to the initial allocation state of the memory page (mp), the corresponding phdr is determined. The phdr is added to the corresponding zbud free list, so that the memory page can be correctly managed and utilized. In the process of taking the metadata corresponding to the initialized memory page as the target metadata, according to the information of the initialized memory page, the segment header (phdr) to which the memory page belongs and other related information can be determined. Through the information of phdr, the metadata structure corresponding to the memory page can be further found. By obtaining the information of the target metadata, corresponding operations can be performed, such as reading and writing data to the memory page, allocating more free blocks, etc. The target metadata can help determine the state and attributes of the memory page for subsequent memory management and operation.

[0149] By the above method, the target metadata can be determined on the memory page in the initial allocation state, ensuring that the memory page can be correctly managed and utilized, while providing necessary information and attributes for subsequent operations. In this way, the effective allocation and management of memory resources can be ensured, while improving the performance and reliability of the operating system.

[0150] As an optional implementation, the method further comprises: in response to not finding the memory block in the memory page in the idle state, allocating a target memory block from the memory management system; initializing metadata of the target memory block to obtain initialized metadata; determining the initialized metadata as the memory block in the memory page in the idle state found, and returning to execute the following step: in response to finding the memory block in the memory page in the idle state, determining the target metadata based on the metadata corresponding to the memory page in the idle state in the structure.

[0151] In this embodiment, when the memory block in the memory page in the idle state is not found, a target memory block can be allocated from the memory management system, the metadata of the target memory block can be initialized, and the initialized metadata can be determined as the memory block found. Thus, in the case of finding the memory block in the memory page in the idle state, the target metadata can be determined based on the metadata corresponding to the memory page in the idle state in the structure, and the memory management system can be a lightweight virtualization memory management ms. The target memory block can be a brand new ms.

[0152] Optionally, it can be checked whether there is a free mp in the zbud, and if not, a brand new ms can be allocated from the memory management system. The virtual address mapping is established and the shdr structure is initialized, and the newly allocated ms is added to the corresponding linked list of the zbud, and finally the newly allocated shdr is returned.

[0153] Optionally, check whether all mps in zbud have been allocated. If there is no free mp available, it indicates that it is currently impossible to allocate a new memory segment directly from zbud. In the case where it is impossible to allocate memory from zbud, a brand new ms needs to be allocated from the lightly virtualized memory management ms. Search for an ms with free mps in the ms_unbuddied linked list, so as to be used for the allocation of the new memory segment. If a qualified ms is found, return the head shdr of the ms. Establish a virtual address mapping for the newly allocated ms, and ensure that the address space of the memory is properly managed. Initialize the shdr structure of the head of the ms, and fill in the necessary information such as the bitmap. It should be noted that the mps recorded in the bitmap of shdr are all free, but the first four mps will be used to save the metadata of the ms, so the bitmap corresponding to the first four mps will be set during initialization, indicating that they have been used. Add the head shdr of the newly allocated ms to the corresponding linked list of zbud, so as to manage and operate the ms subsequently. Update the number of mss ms_nr in zbud, to ensure the consistency of the memory management system. After the initialization and operation are completed, finally return the newly allocated shdr, indicating that a brand new ms has been successfully allocated from the lightly virtualized memory management ms.

[0154] Through the above method, a brand new ms can be successfully allocated from the lightly virtualized memory management ms in the case where no memory block is found, and the ms is properly initialized and added to the memory management system for subsequent memory allocation and management operations.

[0155] In the embodiments of the present disclosure, by allocating a new memory segment from the lightly virtualized memory management ms, the system memory resources can be better utilized, and memory waste can be avoided. In the case where it is impossible to allocate memory from the traditional memory pool, allocating a new memory segment from the ms can improve the flexibility and adaptability of memory management. By establishing a virtual address mapping and properly initializing the newly allocated memory segment, the stability and correctness of the memory management system can be ensured. The newly allocated memory segment is properly initialized and managed, which can improve the performance of memory allocation and access, and reduce unnecessary memory operations and system burden. Adding the newly allocated memory segment to the corresponding linked list of zbud and updating the state of the memory management system can improve the reliability and consistency of the system, and ensure the correctness of the memory management operation. Adopting a clear process and standardized operation steps can improve the readability and maintainability of the code, facilitating subsequent debugging and maintenance work.

[0156] In summary, by allocating a new memory segment from the memory management ms of lightweight virtualization, in the case of memory resource shortage or inability to allocate memory from the traditional memory pool, the resource utilization can be effectively optimized, the system performance and stability can be improved, and the flexibility and reliability of the system can be enhanced. The above technical solution helps to improve the efficiency and reliability of memory management, and improve the overall performance and user experience of the operating system.

[0157] As an optional implementation, the metadata of the target memory block is initialized to obtain initialized metadata, including: determining a plurality of memory pages recorded by a bitmap of the metadata of the target memory block; determining a second target memory page for storing the metadata of the target memory block in the plurality of memory pages; and setting the bitmap corresponding to the second target memory page to obtain the initialized metadata.

[0158] In this embodiment, in the process of initializing the metadata of the target memory block, a plurality of memory pages recorded by a bitmap of the metadata of the target memory block can be determined, and a second target memory page for storing the metadata of the target memory block can be determined in the plurality of memory pages, and the bitmap of the second target memory page can be set to obtain the initialized metadata, wherein the second target memory page can be the first several mp in the shdr, such as the first 4 mp.

[0159] Optionally, in the initialization, the bitmaps in the shdr record that the following memory small blocks (mp) are all free, but the first 4 mp are used to save the metadata of the memory block. Therefore, in the initialization, the bitmap corresponding to the first 4 mp is set, indicating that it has been used.

[0160] Optionally, in the process of initializing the newly allocated ms, the bitmap of the shdr is used to record the allocation state of each memory page in the memory segment. Each bit in the bitmap corresponds to a memory page, and the allocation state of the memory page can be marked by the bitmap, 0 indicating free and 1 indicating allocated. According to the information in the bitmap, the allocation state of the plurality of memory pages and which memory pages have been allocated to the memory segment for use can be determined. In the initialization, the first 4 mp of the shdr will be used to save the metadata of the ms, instead of being used to store data. By allocating and marking the memory pages of the memory segment, it can be determined which memory pages are the first 4 mp used to store metadata. The bitmap corresponding to the first 4 mp is set to obtain the initialized metadata. For the first 4 mp, the corresponding bitmap position is 1, indicating that these memory pages have been used to store the metadata of the ms. The set bitmap can accurately record the use of the first 4 mp, ensuring that these memory pages will not be incorrectly allocated to other data or operations.

[0161] By the above method, the plurality of memory pages recorded in the bitmap of the metadata of the target memory block can be determined, the first four mps storing the metadata of the target memory block can be found, the bitmap corresponding to the first four mps can be set, and it is ensured that the memory pages are correctly used to store the metadata of the memory segment, so that the correct initialization of the metadata is realized. In this way, the effective allocation and management of memory resources by the memory management system can be ensured.

[0162] In the embodiment of the present disclosure, by setting the bitmap corresponding to the first four mps, the memory pages can be accurately marked as being used to store the metadata of the ms. In this way, the accurate tracking and management of the state of the memory pages by the memory management system can be ensured. The memory pages can be prevented from being incorrectly allocated to other data or operations, ensuring that the memory pages are exclusively used for storing metadata and avoiding data confusion and conflicts. Correctly initializing the bitmap corresponding to the first four mps can improve the efficiency of memory management, ensure that the metadata of the memory segment is correctly stored and managed, and avoid resource waste and unnecessary operations. The integrity and correctness of the metadata stored in the target memory block can be ensured, data loss or damage can be avoided, and the consistency and integrity of system data can be ensured. Reasonable use of the bitmap for initialization can improve the stability and reliability of the system, ensure the correctness of memory management operations, and reduce the occurrence of system errors and abnormal conditions. The memory management process can be simplified, the readability and maintainability of the code can be improved, and the memory management operations can be made clearer and more efficient.

[0163] In summary, by setting and initializing the bitmap corresponding to the first four mps, the accuracy, efficiency, and stability of memory management can be effectively improved, the system can be ensured to reasonably allocate and manage memory resources, and the performance and reliability of the system can be improved. The above technical solution helps to optimize memory management operations and improve the overall operating efficiency and stability of the operating system.

[0164] As an optional implementation, in step S308, the memory corresponding to the compressed data is allocated from the memory pool based on the position information, including: searching for the memory at the position corresponding to the position information in the memory pool; and determining the searched memory as the memory corresponding to the compressed data.

[0165] In this embodiment, in the process of allocating the memory corresponding to the compressed data from the memory pool based on the position information, the memory at the position corresponding to the position information in the memory pool can be searched, and the searched memory can be determined as the memory corresponding to the compressed data.

[0166] Optionally, according to the given position information, the corresponding position in the memory pool can be found, which corresponds to a specific position or offset in the memory. After determining the memory position, the corresponding memory data at the position can be found in the memory through the corresponding memory access method or pointer operation. By reading the data in the memory, the original data or compressed data stored at the position can be obtained. According to the characteristics or structure of the compressed data and the association of the position information, it can be determined that the memory at the position corresponds to the compressed data. Once the memory corresponding to the compressed data is determined, corresponding processing operations such as decompression, parsing, reading, etc. can be performed. According to the required operation and processing logic, the memory is operated accordingly to obtain or process the compressed data. After processing the memory corresponding to the compressed data, further data processing, analysis or application can be performed according to specific requirements.

[0167] Through the above method, the memory at the position corresponding to the position information in the structure can be found, and the found memory can be determined as the memory corresponding to the compressed data. In this way, the data in the memory can be effectively managed and operated, and the query, processing and application of the compressed data can be realized.

[0168] Optionally, as the memory allocation is completed, the allocated memory block can cause the maximum free quantity in the mp_list linked list group to change. The maximum free quantity in the mp_list linked list group can be updated to reflect the latest free memory block situation. The allocated memory block is moved to the corresponding new queue according to the new free situation after the maximum free quantity is updated. According to the free quantity and category of the memory block, the memory block is moved to the appropriate queue to manage the memory resources more effectively. With the change of memory allocation, max_idx and max_free also need to be updated accordingly. max_idx represents the starting position index of the largest continuous free segment, and max_free represents the size of the largest continuous free segment. These values need to be updated according to the latest memory allocation situation to ensure the accuracy and efficiency of memory management. After the above steps are performed, the system can update the memory management information, including the allocation state, free situation, queue position, etc. of the memory block. In this way, the memory management system can have new and accurate information to be used in future memory allocation and release processes. Finally, the overall state can be updated to reflect the new memory allocation situation. This includes the free situation of the memory pool, the state of the allocated memory block, the memory usage, etc. By updating the system state in a timely manner, the system can effectively manage memory resources and meet the needs of application programs.

[0169] In summary, the steps after memory allocation completion include updating the maximum free quantity, moving the memory block to a new queue, updating the max_idx and max_free, and other key information to ensure that the memory management system can accurately and efficiently manage memory resources. These steps help the system to track memory usage in real time, optimize the memory allocation process, and improve the performance and stability of the system.

[0170] The embodiments of the present disclosure also provide a memory release method. FIG. 4 is a flowchart of a memory release method according to an embodiment of the present disclosure. As shown in FIG. 4, the method can include the following steps:

[0171] In step S402, the memory to be released is determined in the memory pool corresponding to the structure.

[0172] In the technical solution provided in the above step S402 of the present disclosure, the memory to be released is allocated from the memory pool based on the position information and is used to store compressed data. The memory to be released is a small memory chunk. The compressed data is used to represent the compression result of the data exchanged between the physical memory and the virtual memory. The position information is used to represent the position of the memory to be released in the memory pool corresponding to the structure. The position information is determined based on the target metadata. The target metadata is the metadata found in the structure and matches the capacity of the memory to be released. The structure includes at least the metadata of different memories in the memory pool.

[0173] In this embodiment, according to the given position information, the memory block at the corresponding position is found from the memory pool, and the memory block is used to store compressed data. The position of the memory to be released is determined through the position information for the next operation. According to the capacity of the memory to be released, the target metadata matching the capacity is found from the metadata in the structure. The target metadata usually contains information about the memory block, such as size, state, and belonging segment. The position and attribute of the memory to be released and the storage of the compressed data are determined according to the target metadata. The corresponding compressed data of the memory to be released is determined, which is used to represent the compression result of the data exchanged between the physical memory and the virtual memory. According to the determined position of the memory to be released and the compressed data, the memory release operation is performed. It may be necessary to update the state of the target metadata to mark the memory to be released as idle. According to the operation result of the memory release, the metadata of the corresponding memory block in the structure is updated. It is ensured that the metadata of different memories in the memory pool is correctly updated and managed.

[0174] Through the above method, the memory to be released can be determined in the structure. The position and attribute of the memory to be released are determined according to the position information and the target metadata. The compressed data is processed and the release operation is performed. Finally, the metadata in the structure is updated to ensure the correct release and management of memory resources. In this way, the memory release operation can be effectively processed, and the accuracy and stability of memory management are ensured.

[0175] In step S404, the memory to be released is released.

[0176] In the technical solution provided in the above step S404 of the present disclosure, after determining the memory to be released from the structure, the memory to be released can be released.

[0177] Optionally, according to the given position information and target metadata, the position and attributes of the memory to be released are determined, including the start address, size, state and other information of the memory block. According to the determined position of the memory to be released, the operation of releasing the memory is performed. It may be necessary to mark the memory to be released as idle state, so that the operating system can re-allocate or recycle it. Update the relevant data structure in the memory management system to reflect the operation result of releasing the memory. It may be necessary to update the state and availability information of the corresponding memory block in the memory pool. If the memory to be released is used to store compressed data, additional processing of the compressed data may be required. It may be necessary to decompress the data or clear the relevant information of the compressed data. Ensure the consistency and correctness of the release operation to avoid memory leakage or inconsistency. It may be necessary to check and adjust the memory management state to ensure the effective use and management of memory resources.

[0178] Optionally, after releasing the memory, it may be necessary to re-mark the memory block as available state, so that the system can be re-allocated to other data or operation when needed. Memory recycling and reuse is an important part of memory management, which can improve the utilization and performance of memory resources. It may be necessary to record the relevant information and log of the release operation for tracking and auditing, to help troubleshoot problems and improve the memory management strategy of the system.

[0179] Through the above method, the memory to be released can be released, ensuring the correct release and management of memory resources, and ensuring the correctness and efficiency of the memory management operation of the system. This can ensure the rational use of memory resources and improve the stability and performance of the system.

[0180] By the steps S402 to S404 of the present disclosure, the to-be-released memory is determined in the memory pool corresponding to the structure, wherein the to-be-released memory is allocated from the memory pool based on the position information, and is used to store compressed data, the compressed data is used to represent the compression result of the data exchanged between the physical memory and the virtual memory, the position information is used to represent the position of the to-be-released memory in the memory pool corresponding to the structure, and the position information is determined based on the target metadata, the target metadata is the metadata found in the structure and matched with the capacity of the to-be-released memory, and the structure at least includes the metadata of different memories in the memory pool; and the to-be-released memory is released, thereby achieving the technical effect that the memory can be effectively allocated, and solving the technical problem that the memory cannot be effectively allocated.

[0181] The above method of the embodiment is further introduced below.

[0182] As an optional implementation, the step S404 of releasing the to-be-released memory includes: performing an analysis operation on the position information of the to-be-released memory to obtain an analysis result; and releasing the to-be-released memory based on the analysis result.

[0183] In the embodiment, in the process of performing the release operation on the to-be-released memory, the position information of the to-be-released memory can be analyzed to obtain an analysis result, and the to-be-released memory is released based on the analysis result, wherein the position information can be a handler. The position handler is an encoding or identifier used to represent the position information of the memory block. The handler is a pointer or a marker pointing to a specific memory block, which is used to determine the position and attributes of the memory block in the memory management system. Through the encoding of the handler, relevant information such as the memory segment (ms), the memory page (mp), the serial number of the memory block (chunk), and the number of memory blocks to be processed can be parsed. The analysis result can be the information parsed from the position information, such as ms, mp, chunk serial number, and nr_chk number.

[0184] Alternatively, the handler can be a pointer to the starting address of the memory block, or an encoding value used to uniquely identify the position and attributes of the memory block. By parsing the encoding of the handler, the specific information of the memory block belonging to the memory segment (ms), the memory page (mp), and the memory block (chunk) can be obtained according to the agreed rules or algorithms, including the serial number and the number. Therefore, the handler plays an important role in memory management, which is used to identify and locate a specific memory block, and helps the system to accurately locate and operate the memory resource. By processing the encoding information of the handler, the allocation, release, and operation of the memory block can be effectively managed, and the efficiency and accuracy of memory management can be improved.

[0185] As an optional implementation, the position information of the memory to be released is parsed to obtain a parsing result, including: determining an encoding result corresponding to the position information, wherein the encoding result is obtained by encoding associated information, and the associated information is used to represent information associated with the attributes of the memory units of the segment number in the memory, and the segment number is obtained by converting the capacity, and the segment number is used to represent the number of memory units corresponding to the capacity, and the memory unit is used to represent the smallest memory unit allowed to be allocated in the memory; and the encoding result is parsed to obtain the associated information, wherein the parsing result includes the associated information.

[0186] In this embodiment, in the process of parsing the position information of the memory to be released, the encoding result corresponding to the position information can be determined, and the encoding result can be parsed to obtain the associated information therein, wherein the encoding result can be obtained by encoding the associated information. The associated information can be used to represent information associated with the attributes of the memory units of the segment number in the memory. The associated information can be information such as ms, mp, chunk sequence number, and nr_chk number corresponding to the chunk. The segment number can be obtained by converting the capacity. The associated information can be included in the parsing result.

[0187] Optionally, in the process of parsing the position information of the memory to be released, the encoding information of the given handler is obtained, which can be converted into a suitable data structure or format for further parsing operation. For the encoding information, the memory segment (ms), memory page (mp), and memory block (chunk) sequence number are parsed according to the agreed rules or algorithms. The sequence number and positional relationship of each part need to be determined according to the information contained in the encoding. In the parsing process, other information about the memory to be released may be included, such as the number of memory blocks to be released (nr_chk). According to the indication in the encoding or the parsing rule, the number of memory blocks to be released is determined. According to the parsed ms, mp, chunk sequence number, and nr_chk number, the specific position and attributes of the memory to be released are determined. The parsed information can be used to locate the position of the memory block to be released in the memory management system, and prepare for the release operation. The final parsing result includes the specific sequence number of the memory segment, memory page, and memory block to which the memory to be released belongs, and the number of memory blocks to be released. These parsing results will guide the subsequent memory release operation and ensure the correct release of the specified memory block.

[0188] By the above operation steps, the position information of the to-be-released memory can be parsed according to the given handler code, and a parsing result is obtained, including the serial numbers of the memory segment, the memory page and the memory block, and the number of memory blocks to be released and the like. In this way, the position and attribute of the to-be-released memory can be accurately determined, and accurate guidance is provided for subsequent memory release operations.

[0189] As an optional implementation, based on the parsing result, the to-be-released memory is released, including at least one of the following: based on the identification information of the memory block corresponding to the to-be-released memory in the association information, the virtual address corresponding to the to-be-released memory is determined, and the to-be-released memory is released from the virtual address, wherein the position information includes the virtual address; the target metadata corresponding to the association information is dequeued from the linked list of the structure, and in response to the successful dequeuing of the target metadata from the linked list of the structure, the to-be-released memory is released; the state of the memory unit of the segment number in the association information is updated from the allocation state to the idle state, and in response to the successful update of the state of the memory unit of the segment number to the idle state, the to-be-released memory is released.

[0190] In this embodiment, in the process of releasing the to-be-released memory based on the parsing result, the virtual address corresponding to the to-be-released memory can be determined based on the identification information of the memory block corresponding to the to-be-released memory in the association information, and the to-be-released memory can be removed from the virtual address, that is, the release operation can be performed on the to-be-released memory at the virtual address. In the process of releasing the to-be-released memory, the target metadata corresponding to the association information can be dequeued from the linked list of the structure, and if the target metadata is successfully dequeued from the linked list of the structure, the to-be-released memory can be released. The state of the memory unit of the segment number in the association information can also be updated from the allocation state to the idle state, and if the state of the memory unit is successfully updated, the to-be-released memory can be released. The identification information of the memory block can be the serial number of the ms. The virtual address can be the kernel-mode virtual address information. The target metadata corresponding to the association information can be the shdr and phdr metadata corresponding to the chunk.

[0191] Optionally, in the memory release process, the physical page number (Physical Frame Number, abbreviated as pfn) corresponding to the ms can be determined according to the serial number of the ms, so as to obtain the kernel-mode virtual address corresponding to the ms. In this architecture, the pfn of the ms and the kva are in a fixed mapping relationship. Then, the position of the mp in the memory page can be calculated according to the serial number of the mp, and then the serial number of the chunk is added to calculate the kernel-mode virtual address information of the chunk.

[0192] Optionally, the corresponding pfn can be found according to the sequence number of the ms. The corresponding kva of the ms, i.e. the kernel mode virtual address, can be found according to the pfn. The position of the mp in the memory page can be calculated according to the sequence number of the mp. Adding the sequence number of the chunk, the offset position of the chunk in the ms can be obtained. The kernel mode virtual address information of the chunk can be determined by integrating the kva of the ms, the position of the mp and the offset position of the chunk.

[0193] Through the above method, the position of the memory block to be released in the kernel mode virtual address space can be accurately calculated, and accurate positioning information is provided for subsequent memory release operations. This process ensures the accuracy and efficiency of the memory release operation.

[0194] Optionally, in the memory release process, according to the information extracted in the processing process, the shdr and phdr metadata headers corresponding to the memory block to be released can be directly converted. The shdr is used to describe the information of the memory segment where the entire memory block is located, and the phdr is used to describe the information of the memory page. Once the information of these metadata headers is obtained, it can be removed from the queue of the original zbud mp_list linked list group according to the phdr. The purpose of the above operation is to update the state of the memory page, mark the released memory block, or perform other operations on the memory page. After releasing the memory block and removing it from the original mp_list linked list group, it can be updated to the queue of the new mp_list linked list group, and the current maximum free memory block quantity can be updated.

[0195] Through the shdr and phdr metadata headers converted in the processing process, the state of the memory block and the memory page involved in the release operation can be better understood and managed, so that subsequent memory management operations can be performed. This step ensures the integrity and correctness of the memory release operation.

[0196] Optionally, in the memory release process, for the memory block to be released, the nr_chk small block memories corresponding to the chunk sequence number need to be updated to the idle state. At the same time, the state of the current mp needs to be updated, including marking the released memory block as idle, and updating the maximum free quantity max_free of the current mp and its corresponding sequence number max_idx.

[0197] Optionally, the nr_chk small block memories corresponding to the chunk sequence number of the memory block to be released are marked as idle, i.e. their state is set to unallocated, so as to be used for subsequent reallocation. The maximum free quantity max_free of the current mp is updated, i.e. the maximum continuous free block quantity in the current memory page is updated. The corresponding sequence number max_idx of the current mp is updated, i.e. the starting sequence number of the maximum free block in the current memory page is updated.

[0198] Through this step, it can be ensured that the released memory block is correctly marked as free in the memory page, and the current memory page free block information is updated, providing accurate free block information for subsequent memory allocation operations. This process ensures the accuracy and efficiency of memory management.

[0199] As an optional implementation, the method further comprises: in response to the existence of a memory page in a non-free state in the plurality of memory pages corresponding to the to-be-released memory in the association information, adding the memory page to the linked list of the structure; and in response to the plurality of memory pages being in a free state, releasing the memory page to an upper layer memory block of the memory page, and determining a state of a bitmap corresponding to the memory page as a free state.

[0200] In this embodiment, when there is a memory page in a non-free state in the plurality of memory pages corresponding to the to-be-released memory in the association information, the memory page can be added to the linked list of the structure. When the plurality of memory pages are in a free state, the memory page can be released to an upper layer memory block of the memory page, and a state of a bitmap corresponding to the memory page is determined as a free state.

[0201] Optionally, in the memory release process, if the current mp still has a part of memory blocks that are not released, that is, the mp is not completely free, the mp needs to be added to the queue of the corresponding mp_list linked list group, so that the subsequent memory allocation operation can use the part of the unreleased memory blocks.

[0202] Optionally, it is checked whether the current mp still has unreleased memory blocks, that is, whether the mp still has free blocks. If the mp still has unreleased memory blocks, the mp is added to the queue of the corresponding mp_list linked list group, so that the subsequent memory allocation operation can directly allocate memory from this mp. The purpose of this step is to ensure that the unreleased memory blocks in the memory page can be effectively managed and utilized, and the utilization rate of memory is improved. If the current mp is completely free, then the next step is entered for processing. This step ensures the efficiency of memory management and the rational use of memory resources.

[0203] Optionally, in the memory release process, if the entire mp is free, that is, no memory block is used, the mp needs to be released to the upper layer ms.

[0204] Optionally, it is judged whether the current mp is completely free, that is, all memory blocks in the entire mp have been released. If the entire mp is free, the mp is released to the upper layer ms, that is, the management responsibility of the memory page is returned to the memory segment to which it belongs. The shdr is removed from the original queue of the zbud, and the head information of the memory segment is updated. The bitmap corresponding to the mp is updated and set to a free state, so as to be used for subsequent reallocation.

[0205] Through this step, the entire mp can be effectively processed as idle, and the memory page is released to the upper memory segment, and the management bitmap is updated to ensure the correctness of memory management. This step ensures the effective release and reuse of memory resources.

[0206] Optionally, during the memory release process, if the mp in the updated ms is not completely idle, i.e., there are still some memory blocks in use, the shdr needs to be re-queued to the corresponding queue of zbud according to the current state. The purpose of this step is to re-add the header information of the memory segment to the appropriate queue, so that subsequent memory management operations can correctly process this memory segment.

[0207] Optionally, check whether there are unreleased memory blocks in the mp in the updated ms. If the mp is not completely idle, re-queue the shdr to the corresponding queue of zbud according to the current state, so as to further manage and operate the memory segment. Through this step, it can be ensured that the header information of the memory segment can correctly reflect the current state of the memory page, ensuring the accuracy of memory management and the effective use of memory resources. This step is very important for maintaining the consistency and effectiveness of memory management.

[0208] Optionally, during the memory release process, if it is found that the entire ms is idle after the previous processing, i.e., all mp in the memory segment are not used, the entire ms needs to be returned to the memory management module of the lightweight virtualization. The purpose of this step is to release the management responsibility of the entire memory segment, so that other memory management modules can reuse this part of memory resources.

[0209] Optionally, determine whether the entire ms is idle, i.e., all memory pages in the memory segment are idle. If the entire ms is idle, return the entire ms to the memory management module of the lightweight virtualization, so as to reallocate and manage this part of memory resources.

[0210] Through this step, the entire memory segment can be effectively processed as idle, and the entire memory segment is returned to the upper memory management module, so as to better manage and utilize memory resources. This step ensures the efficiency of memory management and the rational use of resources.

[0211] The embodiments of the present disclosure also provide another memory allocation method. FIG. 5 is a flowchart of a memory allocation method according to an embodiment of the present disclosure. As shown in FIG. 5, the method can include the following steps:

[0212] Step S502, determining data exchanged between the physical memory and the virtual memory.

[0213] In the technical solution provided in step S502 of the present disclosure, the data exchanged between the physical memory and the virtual memory can be determined.

[0214] Optionally, determining the data required to be exchanged between the physical memory and the virtual memory generally involves the operations of page exchange and page replacement. For example, a page replacement algorithm (such as LRU, etc.) is used to determine which pages should be exchanged out of the physical memory to make room for the pages required to be exchanged in from the virtual memory, and the data of the pages required to be exchanged is determined as the data required to be exchanged. For another example, when a page required to be accessed is not in the physical memory, a page fault interrupt is generated. In the page fault interrupt processing, the page required to be replaced can be found. The data in the page required to be replaced can be determined as the data required to be exchanged between the memories.

[0215] It should be noted that the above-mentioned case of determining the data required to be exchanged between the physical memory and the virtual memory is only for illustration and is not limited to the page fault interrupt and the page replacement algorithm, and can also be the case of insufficient memory space and memory recycling, and the present disclosure does not make specific limitations on the case of determining the data required to be exchanged.

[0216] Through the above method and method, the data required to be exchanged between the physical memory and the virtual memory can be determined, and the operations of page replacement and page exchange are realized to meet the management and use requirements of the system on the memory resources. In this way, the memory resources can be effectively managed, and the performance and reliability of the system can be improved.

[0217] In step S504, the data is compressed to obtain compressed data.

[0218] In the technical solution provided in step S504 of the present disclosure, the data can be compressed to obtain the compressed data.

[0219] Optionally, the compression of the exchanged memory can be achieved by the following steps: selecting a suitable data compression algorithm, selecting a suitable compression algorithm according to the characteristics and needs of the data. The exchanged memory data is divided into blocks according to a certain block size to form small block memory data. Each small block memory data is compressed by applying the selected compression algorithm. The original data is converted into compressed data, reducing the storage space of the data. A compressed data index table is maintained to record the mapping relationship of each small block memory data before and after compression, to facilitate subsequent data recovery and management. The compressed small block memory data is stored in the disk or other medium to ensure the persistence and security of the data. When the compressed data needs to be accessed, the corresponding compressed data block is found according to the index table, and the decompression operation is performed to restore the compressed data to the original data. Different data compression algorithms and parameters will affect the compression ratio and performance, which can be optimized and adjusted according to the actual situation to achieve better compression effect and performance.

[0220] Through the above method, the exchanged memory data can be compressed to reduce the storage space of the data, improve the storage efficiency and save storage resources. At the same time, through the management and recovery operation of the compressed data, the compressed data can be effectively managed and operated to meet the system's demand for memory data management. The above method can optimize the memory management and data storage efficiency to a certain extent.

[0221] In step S506, based on the compressed data, the capacity of the to-be-allocated memory is determined, wherein the to-be-allocated memory is used to store the compressed data.

[0222] In the technical solution provided by the above step S506 of the present disclosure, after the data is compressed to obtain compressed data, the capacity of the to-be-allocated memory can be determined based on the compressed data, wherein the to-be-allocated memory can be used to store the compressed data.

[0223] Optionally, the process of determining the size of the memory to be allocated by compressing the data can be carried out according to the following steps: according to the compressed data, decompression operation is performed to restore the compressed data to the original data. The decompressed data will be in the form of the original data, which can be used to determine its actual size and capacity. According to the decompressed data, its actual size and capacity are determined. The size of the memory to be allocated can be determined by obtaining the length or byte number of the data. Considering the possible additional space requirements and storage requirements, the actual capacity of the memory to be allocated is determined according to the specific application scenario and requirements. It may be necessary to reserve a certain buffer or space to ensure the integrity of the data and the smooth execution of the operation. According to the determined size of the memory to be allocated, a memory block of sufficient size is allocated through a memory allocation operation for storing the decompressed data. Ensure that the size of the allocated memory matches the size of the decompressed data to ensure that the data can be stored and operated completely. The decompressed data is stored in the allocated memory block, and necessary data management and operation are performed. Ensure that the data storage and access operation can be carried out normally, and avoid data loss or damage.

[0224] Through the above method, the size of the memory to be allocated can be determined by compressing the data, ensuring that the size of the allocated memory is suitable for storing the decompressed data to meet the data storage and operation requirements. This can effectively manage and utilize memory resources, ensuring the integrity of the data and the stability of the operating system.

[0225] Step S508, in the structure, find the target metadata matching the capacity, wherein the structure at least includes the metadata of different memories in the memory pool.

[0226] In the technical solution provided by the above step S508 of the present disclosure, after determining the capacity of the memory to be allocated based on the compressed data, the target metadata matching the capacity can be found in the structure, wherein the structure at least includes the metadata of different memories in the memory pool.

[0227] Optionally, the capacity of the memory to be allocated is determined, which can be obtained in some way, such as determining according to the requirements or the actual data size. In the metadata of the structure, various information of the metadata is included, which may include the capacity information of the metadata. By traversing the metadata in the structure, the metadata matching the capacity of the memory to be allocated can be found as the target metadata.

[0228] Step S510, based on the target metadata, determine the location information of the memory to be allocated, wherein the location information is used to represent the location of the memory to be allocated in the memory pool corresponding to the structure.

[0229] In the technical solution provided in step S510 of the present disclosure, after determining the target metadata matching the capacity in the structure, the position information of the to-be-allocated memory can be determined based on the target metadata, where the position information is used to indicate the position of the to-be-allocated memory in the memory pool corresponding to the structure.

[0230] Optionally, the target metadata is obtained from the metadata of the structure, and the metadata records the related information of the to-be-allocated memory of the compressed data. The size of the to-be-allocated memory is determined based on the capacity information recorded in the target metadata. According to other information in the target metadata, in combination with the capacity of the to-be-allocated memory, the position information of the to-be-allocated memory in the structure can be determined. According to the determined position information, the memory block corresponding to the compressed data is allocated from the memory pool. In this way, the effective management and allocation of the compressed data are realized.

[0231] In step S512, the memory corresponding to the compressed data is allocated from the memory pool based on the position information.

[0232] In the technical solution provided in step S512 of the present disclosure, after determining the position information of the to-be-allocated memory based on the target metadata, the memory corresponding to the compressed data is allocated from the memory pool based on the position information.

[0233] Optionally, according to the position information of the compressed data and the size of the compressed data, the position information of the memory to be allocated in the structure can be determined. The size of the memory to be allocated is determined according to the size of the compressed data. According to the determined position information and the memory size, the memory block corresponding to the compressed data is allocated from the memory pool. The memory allocation function or the self-defined memory management mode can be used for the memory allocation operation. The compressed data is stored in the allocated memory block, ensuring the correct storage and management of the data. The position information of the allocated memory block is recorded for subsequent operation and management.

[0234] In the embodiment of the present disclosure, the small block memory management refers to a method for managing and processing small block data in the memory. In the virtualization architecture, in order to facilitate the storage of the memory data to be exchanged out, the compressed memory mode can be used. The compressed memory can reduce the memory occupation space and improve the memory utilization rate, but the compressed small block memory also needs to be effectively managed. The memory data to be exchanged out is compressed to a smaller size. This can be realized by using a compression algorithm to reduce the memory occupation space. The compressed small block memory is managed, and the above small block memory management method is applicable to the light virtualization architecture. The virtualization technology can help to isolate and manage different application programs or operating systems, and improve the utilization rate and performance of system resources.

[0235] By adopting the above small block memory management method for lightweight virtualization architecture, the compressed small block memory data can be effectively managed, the memory utilization rate and system performance are improved, and the safety and reliability of the data are ensured. The above method is suitable for scenarios where memory data needs to be compressed and managed, especially in the case of effective management of memory in a virtualization environment.

[0236] By the steps S502 to S512 of the present disclosure, the data exchanged between the physical memory and the virtual memory is determined; the data is compressed to obtain compressed data; based on the compressed data, the capacity of the to-be-allocated memory used for storing the compressed data is determined; in a structure, target metadata matching the capacity is searched, wherein the structure at least includes metadata of different memories in a memory pool; based on the target metadata, position information of the to-be-allocated memory is determined, wherein the position information is used to represent the position of the to-be-allocated memory in the memory pool corresponding to the structure; and based on the position information, the memory corresponding to the compressed data is allocated from the memory pool, thereby achieving the technical effect that the memory can be effectively allocated, and solving the technical problem that the memory cannot be effectively allocated.

[0237] According to the embodiments of the present disclosure, an embodiment of a memory allocation system is also provided. FIG. 6 is a schematic diagram of a memory allocation system according to an embodiment of the present disclosure. As shown in FIG. 6, the memory allocation system 600 can include a memory allocation end 601 and a memory release end 602.

[0238] The memory allocation end 601 is configured to determine the capacity of the to-be-allocated memory, wherein the to-be-allocated memory is used to store compressed data, and the compressed data is used to represent the compression result of the data exchanged between the physical memory and the virtual memory; in a structure, target metadata matching the capacity is searched, wherein the structure at least includes metadata of different memories in a memory pool; based on the target metadata, position information of the to-be-allocated memory is determined, wherein the position information is used to represent the position of the to-be-allocated memory in the memory pool corresponding to the structure; and based on the position information, the memory corresponding to the compressed data is allocated from the memory pool.

[0239] In this embodiment, the capacity of the to-be-allocated memory can be determined in the memory allocation end 601. The metadata matching the above capacity can be searched as target metadata in the metadata in the structure. The position information of the to-be-allocated memory in the structure can be determined according to the target metadata, and the memory corresponding to the compressed data is allocated from the memory pool according to the position information, thereby realizing memory allocation.

[0240] Optionally, when a piece of memory needs to be allocated from the memory pool, the memory can be used as the to-be-allocated memory, and the size of the to-be-allocated memory can be obtained. Determining the capacity of the to-be-allocated memory can help the system ensure that the size of the allocated memory space is sufficient to store compressed data. By determining the memory capacity, memory waste and the like can be avoided, thereby achieving the technical effect of improving memory utilization.

[0241] Optionally, the capacity of the memory that needs to be allocated is determined, which can be obtained in some way, for example, according to the demand or the actual data size. In the metadata of the structure, various information of the metadata is included, which can include capacity information of the metadata. By traversing the metadata in the structure, metadata matching the capacity of the to-be-allocated memory can be found as target metadata. By searching for target metadata matching the capacity, the memory can be more accurately managed and allocated.

[0242] Optionally, the target metadata is obtained from the metadata of the structure, which records the related information of the compressed data to-be-allocated memory. The size of the to-be-allocated memory is determined according to the capacity information recorded in the target metadata. According to other information in the target metadata and the capacity of the to-be-allocated memory, the position information of the to-be-allocated memory in the structure can be determined. According to the determined position information, the memory block corresponding to the compressed data is allocated from the memory pool. In this way, effective management and allocation of compressed data are realized. Through the above method, the position information of the to-be-allocated memory can be determined through the target metadata, ensuring effective allocation and management of the memory.

[0243] Optionally, according to the position information and the size of the compressed data, the position information of the memory that needs to be allocated in the structure can be determined. The size of the memory that needs to be allocated is determined according to the size of the compressed data. According to the determined position information and the memory size, the memory block corresponding to the compressed data is allocated from the memory pool. The memory allocation function or the self-defined memory management mode can be used for memory allocation operation. The compressed data is stored in the allocated memory block, ensuring correct storage and management of the data. The position information of the allocated memory block is recorded for subsequent operation and management.

[0244] Optionally, after the memory corresponding to the compressed data is allocated from the memory pool by the memory allocation end 601, the memory can be transmitted to the memory release end 602.

[0245] The memory release end 602 is configured to release the memory corresponding to the compressed data.

[0246] In this embodiment, after the memory corresponding to the compressed data is received by the memory release end 602, the memory can be released.

[0247] Optionally, according to the given location information and target metadata, the location and attributes of the memory to be released are determined. According to the determined location of the memory to be released, the operation of releasing the memory is performed. It may be necessary to mark the memory to be released as idle in order to be reallocated or recycled by the operating system. The relevant data structure in the memory management system is updated to reflect the result of the operation of releasing the memory. It may be necessary to update the state and availability information of the corresponding memory block in the memory pool. If the memory to be released is used to store compressed data, additional processing of the compressed data may be required. It may be necessary to decompress the data or clear the relevant information of the compressed data. The consistency and correctness of the release operation are ensured to avoid memory leakage or inconsistency. It may be necessary to check and adjust the memory management state to ensure the effective use and management of memory resources.

[0248] In this embodiment, a memory allocation method system is provided. The capacity of the memory to be allocated is determined by the memory allocation end 601; in the structure, the target metadata matching the capacity is found; based on the target metadata, the location information of the memory to be allocated is determined; based on the location information, the memory corresponding to the compressed data is allocated from the memory pool. The memory corresponding to the compressed data is released by the memory release end 602, thereby realizing the technical effect that the memory can be effectively allocated, and solving the technical problem that the memory cannot be effectively allocated.

[0249] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present disclosure, such as data for verification, are all information and data authorized by users or authorized by all parties, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose authorization or refusal.

[0250] Currently, in traditional operating systems, memory swapping is a mechanism that moves data pages in memory to swap space on disk to free up memory and provide space for other processes or applications. In operating systems, LRU algorithm and swap function are usually used to manage memory swapping. However, there are some limitations and deficiencies in traditional operating systems: In traditional operating systems, memory swapping operations usually operate at a page granularity of 4kB. This means that even if only part of the page content needs to be replaced, the entire page needs to be swapped, resulting in waste of resources and reduction of efficiency. The memory swapping mechanism of traditional operating systems does not support swapping at large page (large memory page) granularity. Large pages can improve memory access efficiency and performance, but the traditional swapping mechanism cannot support swapping of large pages. The traditional memory swapping function usually only swaps the pages of user-mode processes, and does not support swapping of kernel-mode pages. Kernel-mode pages contain the code and data of the operating system kernel, and swapping them may cause system crashes or instability.

[0251] In traditional operating systems, if the running operating system is not configured with swap function, and the online swap function can only use file mode, the performance is low, which will seriously affect the stability of the system. In order to solve this problem, a lightweight memory virtualization method can be used to switch the running operating system to a virtualization mode, paving the way for subsequent memory swapping function.

[0252] Memory virtualization is a technology that virtualizes physical memory resources into multiple logical memory spaces. Through memory virtualization, the memory resources of the running operating system can be virtualized into an independent memory area, allowing it to run in an independent environment without affecting the original operating system. Through memory virtualization technology, the running operating system can be switched to a virtualization mode. In the above mode, the operating system can run in an isolated environment without negatively affecting the stability and performance of the physical system. After switching the operating system to the virtualization mode, the memory swapping function can be enabled in the virtualization environment without affecting the physical system. By enabling the memory swapping function in the virtualization environment, the memory utilization of the system can be improved, the memory pressure can be reduced, and the performance and stability of the system can be improved.

[0253] Through memory virtualization technology, the isolation and independent running of the running operating system can be achieved, thereby reducing the impact on the physical system. Enabling the memory swapping function in the virtualization environment can improve the stability and performance of the system while avoiding interference with the original operating system.

[0254] However, the above operating system has the problem of too fine granularity, which reduces the performance and stability of the operating system, and therefore there is still a technical problem of being unable to effectively allocate memory.

[0255] Further, the disclosure provides a small block memory management method of a lightweight virtualization architecture, which solves the technical problem of being unable to effectively allocate memory. Unlike the conventional solution in which memory pages are 4k granularity and do not support large page granularity, the memory exchange function currently indicates pages for a user mode process and does not support the exchange of kernel mode pages, solving the technical problem of being unable to effectively allocate memory.

[0256] In the embodiments of the disclosure, the above-mentioned memory allocation method, memory release method, and memory management method, and the above-mentioned small block memory management method can be performed after switching a running operating system (which can also be referred to as a host operating system) to a virtualization mode (which can also be referred to as a guest operating system), that is, memory management, allocation, and release in a newly inserted lightweight virtualization layer of the guest operating system after switching to the guest operating system. Specifically, when switching to the guest operating system, the memory in the above-mentioned host operating system can be exchanged to the guest operating system, and for the exchanged memory in the guest operating system, the compressed data of the memory exchange is managed in the newly inserted virtualization layer.

[0257] It should be noted that the above-mentioned scenarios of applying the small block memory management method and the like of the embodiments of the disclosure are only for illustration. The above-mentioned small block memory management method and the like of the embodiments of the disclosure are not limited to being performed after switching to the virtualization mode, and can also be applied to other non-virtualization scenarios, such as being directly used to manage the small block memory stored in the existing memory compression mechanism. In the embodiments of the disclosure, the scenarios to which the small block memory management method and the like can be applied are not specifically limited, and as long as the scenarios can apply the above-mentioned methods provided by the disclosure, they are within the protection scope of the embodiments of the disclosure.

[0258] In the embodiments of the disclosure, the compressed memory is used to reduce memory occupation and transmission overhead. In the process of frequently performing memory exchange, the small block memory after compression can be more efficiently stored and transmitted, thereby improving the performance and resource utilization of the operating system, and through small block memory management, the memory exchange and compression operation in the virtualization environment can be better supported. Through the above-structured memory management method, the effective storage and exchange of compressed data between physical memory and virtual memory are ensured. Through the processes of searching for target metadata, determining position information, and allocating memory, effective management and allocation of compressed data are realized, the performance and efficiency of the operating system are improved, and thus the technical effect of being able to effectively allocate memory is realized, solving the technical problem of being unable to effectively allocate memory.

[0259] The above-mentioned method of the embodiment will be further introduced below.

[0260] In this embodiment, a management structure of small memory of a lightweight virtualization architecture is proposed. Through the above setting, the small memory can be effectively managed and allocated. Through the management of the linked list and the metadata structure, efficient utilization and allocation of the memory are realized. At the same time, through detailed granularity division and metadata recording, the allocation and release of the memory can be more flexibly managed. The above lightweight virtualization architecture has good support for the efficiency and flexibility of memory management.

[0261] FIG. 7(a) is a flowchart of a management method of small memory of a lightweight virtualization architecture according to an embodiment of the present disclosure. As shown in FIG. 7(a), the method can include the following steps:

[0262] Step S701, a memory block is divided to obtain a plurality of memory pages.

[0263] In this embodiment, a memory block (assuming a size of 2m) is divided into a plurality of small segments, which are divided by 4k as the granularity, and each small segment is referred to as an mp. In the above case, the 2m memory block is divided into 512 4k memory pages, and each memory page corresponds to an mp.

[0264] The above division method can effectively divide a large memory block into small blocks, which facilitates the management and allocation of the memory. The size of each mp is 4k, which is the most basic memory management unit in the operating system and is used to store data and program carriers. By dividing the memory block into a plurality of memory pages, the memory can be more flexibly managed, and the utilization and efficiency of the memory can be improved.

[0265] Optionally, a 2m memory block is divided into 512 4k memory pages, and each memory page is referred to as a memory page, which can provide the function of fine management of the memory and optimization of the memory utilization.

[0266] Step S702, the memory pages are divided to obtain a plurality of memory small blocks.

[0267] In this embodiment, a memory block (assuming a size of 4k) is divided into a plurality of small segments, which are divided by 64B as the granularity, and each small segment is referred to as a memory small block. In the above case, the 4k memory block is divided into 64 64B memory small blocks, and each memory small block is referred to as a Chunk. The above division method can more finely divide the memory block into small blocks to adapt to more fine memory management requirements. The size of each Chunk is 64B, and the above granularity is smaller, which can more flexibly perform memory allocation and release, and improve the utilization and management efficiency of the memory.

[0268] Optionally, a 4k memory block is divided into 64 64B memory blocks, each of which is referred to as a memory block chunk, so as to realize more detailed memory management and more fine memory allocation. The above division mode is suitable for a scenario with high requirement for memory management accuracy.

[0269] In step S703, metadata is stored in the first four memory pages in the plurality of memory pages.

[0270] In this embodiment, the first 4 memory pages in all the mps of the whole memory block (assuming ms) are used as the storage positions of the metadata structures (headers) of various segments in the whole memory block.

[0271] Optionally, the first memory page stores a metadata structure shdr for managing memory pages. The size of the shdr is 128 bytes, which is equal to the size of 4 memory pages, and is used for managing the memory pages in ms. The next three memory pages respectively store 508 metadata structures phdr for managing memory blocks. The size of each phdr is 32 bytes, and is used for managing the memory blocks in ms.

[0272] In the above manner, no additional memory space is allocated for the metadata structures, but the first 4 mps of ms are used to store the metadata structures for managing various segments. In this way, memory space can be saved, and the metadata structures can be directly accessed in the memory block, facilitating the management and operation of the segments in the memory block.

[0273] Optionally, the first 4 memory pages in the whole memory block are used to store the metadata structures for managing various segments, including the shdr for managing memory pages and the phdr for managing memory blocks. The above design saves the memory space for allocating the metadata structures, and improves the efficiency and flexibility of memory management.

[0274] In step S704, the metadata in the lightweight virtualization architecture is managed through the structure.

[0275] In this embodiment, the overall small block memory management metadata is contained in a total structure body named zbud, which contains the following fields: the number of ms obtained by the small block memory pool, which records the number of ms in the small block memory pool that have been obtained. The full ms linked list ms_buddied stores the linked list of full ms, which is used to manage the allocated full memory blocks. The half-full ms linked list ms_unbuddied stores the linked list of half-full ms, which is used to manage the partially allocated memory blocks. The ms linked list lock (ms_list_lock) is used to protect the mutex lock of the ms linked list, ensuring that the operation on the ms linked list is thread-safe. The mp linked list array group (mp_list_chain_table_group) of various free quantities (free quantities from 1-63) contains the mp linked list array from 1 free memory block to 63 free memory blocks, which is used to manage memory blocks of different free quantities. The mp_list_chain_table_group_lock is used to protect the mutex lock of each linked list of the mp linked list array, ensuring that the operation on the mp linked list is thread-safe.

[0276] Through this zbud total structure body, the ms and mp in the small block memory pool can be effectively managed, including the allocated and free memory blocks and memory blocks. At the same time, by using the linked list and lock mechanism, the management of memory blocks and memory blocks can be ensured to be safe and efficient.

[0277] Optionally, the zbud total structure body contains the management metadata of the memory blocks and memory blocks in the small block memory pool, including the allocated and free memory block linked list, mutex lock and other information, which is used to realize the efficient management of the small block memory. The above design can improve the efficiency and flexibility of memory management, which is suitable for scenarios with high requirements for memory allocation and release.

[0278] Step S705, record the important information of the memory block through the segment header of the memory block.

[0279] In this embodiment, the metadata header shdr of the ms contains the following information: the physical address paddr of the memory block ms, which records the starting address of the memory block ms in the physical memory, used for locating and accessing the memory block; the mapped kernel virtual address kva of the memory block ms, which records the mapped address of the memory block ms in the kernel virtual address space, used for kernel access and management of the memory block; the allocation bitmap bitmap of the memory pages mp in the memory block ms, which records the allocation status of each memory page mp in the memory block ms, indicating which memory pages have been allocated and which are free in the form of a bitmap; the number of free memory pages mp in the memory block ms, which records the number of free memory pages mp in the memory block ms, used for quick allocation of free memory pages; the lock for managing mp allocation and release, which is used to ensure thread safety of the operation on the memory pages mp in order to protect the allocation and release of the memory pages mp. The ms header is linked to the node node of the ms linked list in the above zbud, which links the node of the memory block ms header to the ms linked list in the zbud total structure, used for organizing and managing the memory blocks ms.

[0280] Through these metadata information, the memory block ms can be effectively managed and operated. Recording the physical address and virtual address, the memory page allocation status, the number of free memory pages, and other information helps to quickly locate and operate the memory block, improving the efficiency and accuracy of memory management. At the same time, by linking to the node of the ms linked list in the zbud total structure, the overall management and organization of the memory block is realized.

[0281] Optionally, the metadata header shdr of the ms records important information about the memory block, including the physical address, the virtual address, the memory page allocation status, the number of free memory pages, the management lock, etc., for efficient management and operation of the memory block. The above design improves the flexibility and efficiency of memory management.

[0282] Step S706, according to the allocation status of the memory pages in the memory block, determine the mounted linked list.

[0283] In this embodiment, in the memory block ms, if all the memory pages mp are allocated, the memory block ms will be mounted to the ms_buddied linked list; if only part of the memory pages mp are allocated and there are free memory pages mp, the memory block ms will be mounted to the ms_unbuddied linked list.

[0284] The above management method can effectively distinguish between fully allocated and partially allocated memory blocks, facilitating the management and allocation of memory blocks by the system. The full ms linked list is used to store memory blocks that have been fully allocated, while the half ms linked list is used to store memory blocks that have been partially allocated, thereby realizing the management and optimization of memory blocks in different states.

[0285] Optionally, based on the allocation of memory pages (mp) within the memory block (ms), the memory block (ms) can be attached to either a fully full (ms) linked list or a half-full (ms) linked list. This management method facilitates the classification and management of memory block states, improving the efficiency and flexibility of memory management.

[0286] Optionally, attaching partially allocated memory blocks to the `ms_unbuddied` linked list has certain significance and benefits, achieving the following functions: Effective management of partially allocated memory blocks: Attaching partially allocated memory blocks to the `ms_unbuddied` linked list facilitates the management of these blocks, placing them within a unified management scope. Attaching partially allocated memory blocks to the `ms_unbuddied` linked list reduces the overhead of memory allocation and deallocation. When a new memory request arrives, an available partially allocated memory block can be first searched in the `ms_unbuddied` linked list, avoiding unnecessary memory allocation operations. By attaching partially allocated memory blocks to the `ms_unbuddied` linked list, memory resources can be utilized more flexibly. Even if a memory block is only partially allocated, it can be quickly reallocated to other requests when needed, improving memory utilization. Attaching partially allocated memory blocks to the `ms_unbuddied` linked list facilitates memory management and scheduling. These memory blocks can be flexibly manipulated according to specific memory requirements, improving the efficiency and flexibility of memory management.

[0287] In summary, attaching partially allocated memory blocks to the ms_unbuddied linked list can improve memory resource utilization, optimize memory management performance, facilitate memory management and scheduling, and thus improve overall system performance and efficiency.

[0288] Step S707: Record important information about the memory page in the page header.

[0289] In this embodiment, the following information is recorded in the metadata header (phdr) of the memory block: `free`: Records the number of free memory segments in this memory block, used for quickly acquiring free memory segments. `max_free`: Records the size of the largest contiguous free memory segment in this memory block, used to optimize memory allocation and release. `max_idx`: Records the starting position number of the largest contiguous free memory segment, used for locating and managing contiguous free memory segments. `lock`: Manages the allocation and release of chunks, used to protect the allocation and release operations of memory blocks, ensuring that operations on memory blocks are thread-safe. `node`: Links the memory block header to the `mp` linked list in the zbud: Links the node of the memory block header to the `mp` linked list in the overall zbud structure, used to organize and manage all memory blocks.

[0290] Through these metadata information, the memory chunks can be effectively managed and operated. Recording the number of free memory segments, the size and location of the largest continuous free segment, and other information can help improve the efficiency of memory chunk allocation and release, and optimize memory management. At the same time, by linking to the mp linked list node in the zbud total structure body, the overall management and organization of the memory chunks are realized.

[0291] Optionally, important information about the memory chunks is recorded in the metadata header phdr of the memory chunks, including the number of free memory segments, the size and location of the largest continuous free segment, management locks, etc., for efficient management and operation of the memory chunks. The above design improves the flexibility and efficiency of memory management.

[0292] In step S708, according to the free condition and the maximum free number of the memory chunks, the completely allocated and partially allocated memory chunks are put into different linked lists for association.

[0293] In this embodiment, in the management of the memory chunks, all the segmented segments are mounted in different linked lists according to the number of the largest free chunks.

[0294] Optionally, if all the segmented memory chunks have been allocated, i.e., there is no free chunk, these completely allocated memory chunks will be put into a specific linked list. These completely allocated memory chunks will be put into the linked list with sequence number 0 in the mp_list linked list group array of zbud. If some memory chunks are allocated and there are still free chunks, these partially allocated memory chunks will be put into the corresponding mp_list linked list group according to the number of the largest free chunks. Specifically, according to the number of the largest free chunks of each memory chunk, these partially allocated memory chunks are put into the corresponding mp_list linked list group.

[0295] In the above manner, the memory chunks can be allocated to different linked lists for management according to the free condition and the number of the largest free chunks. The above management manner can optimize the allocation and release of the memory chunks, and improve the efficiency and flexibility of memory management.

[0296] Optionally, according to the free condition and the number of the largest free chunks, the completely allocated and partially allocated memory chunks are put into different linked lists for management. The above management manner helps to classify and manage the state of the memory chunks, and improves the efficiency and flexibility of memory management.

[0297] In the embodiments of the present disclosure, a small block memory allocation algorithm of a lightweight virtualization architecture is also proposed, which can effectively manage and allocate small block memory, and improve the efficiency and flexibility of memory management. Through detailed memory allocation process and data structure design, efficient management and operation of small block memory are realized.

[0298] FIG. 7(b) is a flowchart of a small block memory allocation method of a lightweight virtualization architecture according to an embodiment of the present disclosure. As shown in FIG. 7(b), the method can include the following steps:

[0299] Step S709, converting the capacity of the memory block into the number of segments.

[0300] In this embodiment, when it is desired to allocate a small block of memory from the zbud pool (memory pool), according to the required memory size size and the granularity of the small block (64 bytes), the required number of small blocks nr_chk is converted, and it is ensured that nr_chk is greater than or equal to size.

[0301] This process is mainly to calculate the actual number of small blocks nr_chk required for allocation according to the actual memory size size and the granularity of system memory management (64 bytes). If the required memory size size is an integer multiple of the small block, then nr_chk is the result of size divided by 64 bytes; if it is not an integer multiple, then it needs to be rounded up to ensure that the number of small blocks allocated can meet the required memory size.

[0302] This conversion process is to ensure that memory allocation is performed according to the granularity of system memory management, and to accurately calculate the required number of small blocks, so that subsequent memory allocation and management operations can be processed according to the granularity. This can ensure the accuracy and efficiency of memory allocation.

[0303] Step S710, searching the linked list of the memory pool to find whether there is metadata that meets the number of segments.

[0304] In this embodiment, according to the previously calculated required number of small blocks nr_chk, first search the zbud mp_list linked list group to find whether there is an already partially allocated mp header phdr, and the memory small block meets the requirement of nr_chk.

[0305] Optionally, first check the mp_list linked list group of the zbud, to find whether there is a partially allocated mp header phdr. If a partially allocated phdr that meets the nr_chk requirement is found in the mp_list linked list group, i.e. the memory chunk can meet the requirement of allocating nr_chk small segments, directly return the found phdr, and jump to the subsequent processing step S715. If there is no partially allocated phdr that meets the nr_chk requirement in the mp_list linked list group, continue to execute the subsequent step S711.

[0306] The purpose of this step is to try to find whether there is a memory block that meets the requirement of the required number of continuous small segments from the partially allocated memory chunk, to avoid allocating a new memory block, and improve the efficiency of memory allocation. If a partially allocated memory chunk that meets the requirement is found, the memory chunk can be directly used for allocation, otherwise the subsequent processing needs to be continued.

[0307] Step S711, judge whether a memory block of the idle memory page is found from the linked list.

[0308] In this embodiment, the ms_undbuddied linked list of the zbud can be searched to find whether there is a free ms, and if yes, step S713 can be executed, otherwise step S712 can be executed.

[0309] Step S712, allocate a brand new memory block from the memory block of the lightweight virtualization memory management.

[0310] In this embodiment, if the free part of all memory chunks in the zbud cannot meet the allocation requirement, i.e. no partially allocated mp is found to meet the requirement of nr_chk, a new mp needs to be allocated from the upper-layer ms to be split.

[0311] Optionally, try to find an ms that still has a free memory chunk from the ms_unbuddied linked list of the zbud. If an ms that still has a free memory chunk is found, return the header shdr of the memory block, and jump to the subsequent processing step S713. If no ms that still has a free memory chunk is found in the ms_unbuddied linked list, continue to execute the subsequent step S712.

[0312] In this step, try to allocate a new mp from the upper-layer ms to meet the requirement of nr_chk small segments, to ensure that the requirement of memory allocation can be met. If the memory chunk in the zbud cannot meet the allocation requirement, a new memory chunk needs to be allocated from a larger ms, and the memory management structure needs to be updated, so as to facilitate subsequent memory allocation and management operations.

[0313] Step S713, allocating a memory chunk from the memory block segment header that meets the allocation requirements, updating the state of the segment header, and connecting the updated state to the corresponding linked list.

[0314] In this embodiment, when there is no free mp available in the zbud, a brand new ms needs to be allocated from the lightweight virtualized memory management structure (ms).

[0315] Optionally, a brand new ms is allocated from the lightweight virtualized memory management structure (ms). A virtual address mapping is established for the newly allocated ms, and the shdr structure in the memory block header is initialized. The newly allocated ms is added to the corresponding linked list of the zbud, and the number of memory blocks ms nr in the zbud is updated. In the initialization, the bitmap in the shdr records that the following mps are all free, but the first four mps are used to save the metadata of the memory block. Therefore, in the initialization, the bitmap corresponding to the first four mps is set, indicating that it has been used. After the initialization is completed, the memory block header shdr is finally returned.

[0316] The operation of this step is to ensure that when there is not enough free memory chunk available in the zbud, a new memory block can be allocated from a larger memory block to meet the memory allocation requirements. Through the above process, the allocation and release of memory blocks can be effectively managed, ensuring the effectiveness and reliability of memory management.

[0317] Step S714, initializing the memory page just allocated.

[0318] In this embodiment, in this step, the memory block header shdr that can meet the allocation requirements has been found, and the next step is to allocate an mp from this memory block header shdr to further allocate the Chunk.

[0319] Optionally, an mp is allocated from the found memory block header shdr that can meet the allocation requirements for further memory block allocation. The memory block header shdr is removed (dequeued) from the original zbud linked list. According to the bitmap of the memory block header shdr, an idle mp is found and set to the allocated state. According to the state of the current ms, the memory block header shdr is re-linked to the full or half-full state queue in the zbud to meet the memory management requirements, improve the performance and efficiency of the system, so that the state and allocation of the memory block can be better managed.

[0320] Through the operation of this step, an mp is allocated from the memory block header shdr meeting the allocation requirements, and the state of the memory block header shdr and the corresponding link table linked to zbud are updated. In this way, the allocation and release of the memory block can be effectively managed, and the accuracy and efficiency of memory allocation are ensured.

[0321] In step S715, a number of subsequent memory segments are set to an allocation state, and the allocation position sequence number is recorded.

[0322] In this embodiment, the allocated mp is initialized.

[0323] Optionally, the newly allocated mp is initialized and set to an initial value: the maximum free number max_free is set to 64, indicating the number of the largest continuous free memory segments in the memory block. The max_idx is set to 0, indicating the sequence number of the starting position of the largest continuous free memory segment. The memory block header phdr corresponding to the allocated mp is added to the corresponding zbud free list: the phdr is added to the corresponding zbud free list to manage and record the state and free condition of the memory block. Through the above operation, the initial state and management of the newly allocated mp are correctly set and recorded. In this way, the memory management and allocation can be orderly performed, and the accuracy and efficiency of memory allocation are ensured.

[0324] In step S716, the largest free number and its corresponding sequence number are scanned from the current memory page, and the memory page is re-queued to the corresponding list according to the current free state.

[0325] In this embodiment, a memory block header phdr meeting the allocation requirements has been obtained, and further processing of the memory block header is required, including setting the subsequent nr_chk memory blocks to an allocation state, recording the allocation position chk sequence number, and the like.

[0326] Optionally, the memory block header phdr meeting the allocation requirements found from the corresponding list of zbud is dequeued, that is, removed from the list. According to the max_idx position recorded in the memory block header phdr, the subsequent nr_chk memory blocks are set to an allocation state. That is, according to max_idx and nr_chk, the range of memory blocks that need to be set to an allocation state is determined. The allocation position chk sequence number is recorded to identify the position and order of the allocated memory blocks.

[0327] Through the above operation, it is ensured that the found memory block header phdr satisfying the allocation requirement is correctly processed and marked, the memory small block to be allocated is set to the allocation state, and the allocation position and serial number are recorded. In this way, the allocation and state of the memory block can be effectively managed, and the accuracy and effectiveness of memory allocation are ensured.

[0328] In step S717, the corresponding kernel mode virtual address is returned according to the allocated serial number, which is used to save compressed data, and the relevant information can also be encoded into a handler.

[0329] In this embodiment, the newly allocated mp can be traversed to re-scan the free state in the current memory small block, find the number of the largest continuous free memory small segments max_free and the corresponding starting position serial number max_idx. Subsequently, according to the current free state, the memory small block is re-inserted into the mp_list linked list group of zbud.

[0330] Optionally, the above allocated mp is traversed to re-scan the free state in the current memory small block. The number of the largest continuous free memory small segments max_free in the current memory small block and the corresponding starting position serial number max_idx are found. According to the current largest free max_free number, the memory small block is re-queued into the mp_list linked list group array of zbud, and according to the number of the largest continuous free memory small segments max_free, it is inserted into the corresponding free linked list position.

[0331] Through the operation of this step, the re-scanning and re-insertion of the newly allocated memory small block into the memory management structure are realized, and the update of the free state and position information of the memory small block is ensured. In this way, the state and free condition of the memory small block can be effectively managed, and the efficiency and accuracy of memory management are improved.

[0332] Optionally, according to the previously allocated chk serial number, the corresponding kernel mode virtual address can be returned, which can be used for subsequent saving of compressed data. In addition, the chunk corresponding to the ms, mp, chunk serial number, nr_chk number, nr_chk size, and the difference diff between the allocation size size can be combined into an encoding handler. The function of this encoding handler is to locate the position of this memory in zbud in order to perform other operations. Through this encoding handler, the ms, mp, and specific chunk position of this memory can be quickly and accurately found, so that operations such as releasing memory, modifying memory content, etc. can be performed.

[0333] In summary, by combining the relevant information into the encoding handler, the allocated memory can be conveniently managed and operated, and the memory utilization efficiency and management efficiency are improved. The above method makes the subsequent memory operation more flexible and efficient.

[0334] In the embodiments of the present disclosure, a memory release algorithm of a lightweight virtualization architecture is provided. When a small memory chunk needs to be released and moved out of the zbud, the relevant ms, mp, chunk sequence number and nr_chk number are parsed according to the provided handler encoding, and then the memory is released. Through this memory release algorithm, the lightweight virtualization architecture can efficiently release and manage the memory, fully utilize the state and location information of the memory block during the release process, and ensure the reasonable utilization of the memory. This algorithm makes the memory release process more intelligent and efficient.

[0335] FIG. 7(c) is a flowchart of a small memory release method of a lightweight virtualization architecture according to an embodiment of the present disclosure. As shown in FIG. 7(c), the method can include the following steps:

[0336] In step S718, the associated information is obtained by parsing the handler.

[0337] In this embodiment, when a small memory chunk needs to be moved out of the zbud, the position identifier used is the handler, and the size is size. According to the encoding of the handler, the following information can be parsed: parse ms: according to the information in the handler, the memory block structure ms to which the memory block belongs, i.e., the large memory area where the memory block is located, can be determined. Parse mp: according to the information in the handler, the memory page structure mp where the memory block is located, i.e., the memory page where the memory block is located, can be determined. Parse chunk sequence number: according to the information in the handler, the specific chunk sequence number of the memory block in the memory page, i.e., the position of the memory block in the memory page, can be determined. Parse nr_chk number: according to the information in the handler, the number of consecutive chunks occupied by the memory block, i.e., the size of the memory block, can be determined.

[0338] Optionally, in the data compression process, the chunk difference information can also be included, that is, when the data is compressed, the data is divided into multiple blocks for processing, and the difference information of each block relative to the previous block is recorded. The above method helps to improve the compression efficiency, especially for cases involving a large amount of repeated data.

[0339] In the compressed data, due to the adoption of chunk difference information, the compressed size is not necessarily an integer multiple of the chunk. This means that there may be a difference part in the compressed data, that is, the compressed data size may not be evenly allocated to each chunk, resulting in the size of the last chunk being less than a complete chunk size. Therefore, during decompression, the accurate size of the stored data, including the difference information, needs to be known to correctly restore the original data.

[0340] During decompression, each chunk needs to be restored according to the chunk difference information first, and then the chunks are combined to obtain the original complete data. Due to the existence of difference information, the last chunk needs to be specially processed during decompression to ensure the integrity and accuracy of the restored data.

[0341] In summary, chunk difference information plays an important role in optimizing compression efficiency in data compression, but attention needs to be paid to processing difference information during decompression to ensure that the original data can be correctly restored. This data compression method can improve the compression ratio to some extent and is suitable for scenarios that require efficient compression and decompression.

[0342] By parsing the handler, the location and size of the memory block to be removed in the zbud can be accurately located and identified, and corresponding operations such as releasing memory or reallocating memory can be performed. This process ensures the accuracy and efficiency of memory operations.

[0343] In step S719, the location of the memory block to be released in the kernel virtual address space is calculated through the association information.

[0344] In this embodiment, during the memory release process, the pfn corresponding to the ms can be determined according to the serial number of the ms, and the kva corresponding to the ms can be obtained. In this architecture, the pfn and kva of the ms are in a fixed mapping relationship. Then, the location of the mp in the memory page can be calculated according to the serial number of the mp, and then the kernel virtual address information of the chunk can be calculated by adding the serial number of the chunk.

[0345] Optionally, the corresponding pfn is found according to the serial number of the ms. The corresponding kva, i.e. the kernel virtual address of the ms, is found according to the pfn. The location of the mp in the memory page is calculated according to the serial number of the mp. By adding the serial number of the chunk, the offset position of the chunk in the ms can be obtained. The kernel virtual address information of the chunk can be determined by combining the kva of the ms, the location of the mp, and the offset position of the chunk.

[0346] Through the above method, the position of the memory block to be released in the kernel virtual address space can be accurately calculated, and accurate positioning information is provided for subsequent memory release operations. This process guarantees the accuracy and efficiency of the memory release operation.

[0347] In step S720, the metadata header corresponding to the memory is converted out.

[0348] In this embodiment, during the memory release process, according to the information extracted during processing, the shdr and phdr metadata headers corresponding to the memory block to be released can be directly converted out according to the sequence numbers of ms and mp. shdr is used to describe the information of the memory segment where the entire memory block is located, and phdr is used to describe the information of the memory page. Once the information of these metadata headers is obtained, it can be removed from the queue according to phdr. The purpose of this operation may be to update the state of the memory page, mark the released memory block, or perform other operations on the memory page.

[0349] Through the shdr and phdr metadata headers converted during processing, the state of the memory block and the memory page involved in the release operation can be better understood and managed, so that subsequent memory management operations can be performed. This step ensures the integrity and correctness of the memory release operation.

[0350] In step S721, the states of the segment number of memory small blocks corresponding to the memory small block sequence number are updated to free state, and the maximum free number of the current memory page and the corresponding sequence number are updated.

[0351] In this embodiment, during the memory release process, for the memory block to be released, the nr_chk small block memories corresponding to the chunk sequence number of the memory block to be released are updated to free state. At the same time, the state of the current mp can be updated, including marking the released memory block as free state, and updating the maximum free number max_free of the current mp and the corresponding sequence number max_idx.

[0352] Optionally, the nr_chk small block memories corresponding to the chunk sequence number of the memory block to be released are marked as free state, i.e. their state is set to unallocated state, so as to be used for subsequent reallocation. The maximum free number max_free of the current mp is updated, i.e. the maximum continuous free block number in the current memory page is updated. The corresponding sequence number max_idx of the current mp is updated, i.e. the starting sequence number of the maximum free block in the current memory page is updated.

[0353] Through this step, it can be ensured that the released memory block is correctly marked as free in the memory page, and the current memory page free block information is updated, providing accurate free block information for subsequent memory allocation operations. This process ensures the accuracy and efficiency of memory management.

[0354] Step S722, judge whether the memory page is not completely free.

[0355] In this embodiment, it can be judged whether the ms is not completely free, if so, step S723 can be executed, otherwise, step S724 can be executed.

[0356] Step S723, add the memory page to the corresponding linked list queue.

[0357] In this embodiment, in the memory release process, if the current mp still has part of the memory block not released, that is, the mp is not completely free, the mp needs to be added to the queue of the corresponding mp_list linked list group, so that the subsequent memory allocation operation can use this part of the unreleased memory block.

[0358] Optionally, check whether the current mp still has unreleased memory block, that is, check whether the mp still has free block. If the mp still has unreleased memory block, add the mp to the queue of the corresponding mp_list linked list group, so that the subsequent memory allocation operation can directly allocate memory from this mp. The purpose of this step is to ensure that the unreleased memory block in the memory page can be effectively managed and utilized, and the utilization rate of memory is improved. If the current mp is completely free, then the next step is entered for processing. This step ensures the efficiency of memory management and the rational use of memory resources.

[0359] Step S724, if the entire memory page is free, the memory page is released to the memory block of the upper layer, and if the updated memory page is not completely free, it is re-queued according to the current state.

[0360] In this embodiment, in the memory release process, if the entire mp is free, that is, there is no memory block used, then the mp needs to be released to the ms of the upper layer.

[0361] Optionally, judge whether the current mp is completely free, that is, all memory blocks in the entire mp have been released. If the entire mp is free, release the mp to the ms of the upper layer, that is, return the management responsibility of the memory page to the memory segment to which it belongs. Remove the shdr from the original queue of the zbud, ensure that the header information of the memory segment is updated. Update the bitmap corresponding to the mp, and set it to the free state, so as to be used for subsequent reallocation.

[0362] Through this step, the entire mp can be effectively processed as idle, and the memory page is released to the upper layer memory segment, and the management bitmap is updated to ensure the correctness of memory management. This step ensures the effective release and reuse of memory resources.

[0363] Optionally, in the process of memory release, if the mp in the updated ms is not completely idle, i.e., there are still some memory blocks in use, the shdr needs to be re-queued to the corresponding queue of zbud according to the current state. The purpose of this step is to re-add the header information of the memory segment to the appropriate queue, so that subsequent memory management operations can correctly process this memory segment.

[0364] Optionally, check whether there are unreleased memory blocks in the mp in the updated ms. If the mp is not completely idle, re-queue the shdr to the corresponding queue of zbud according to the current state, so as to further manage and operate the memory segment. Through this step, it can be ensured that the header information of the memory segment can correctly reflect the current state of the memory page, ensuring the accuracy of memory management and effective use of memory resources. This step is very important for maintaining the consistency and effectiveness of memory management.

[0365] Step S725, return the entire memory page to the memory management module of the lightweight virtualization.

[0366] In this embodiment, in the process of memory release, if it is found that the entire ms is idle after the previous processing, i.e., all the mps in the memory segment are not used, the entire ms needs to be returned to the memory management module of the lightweight virtualization. The purpose of this step is to release the management responsibility of the entire memory segment, so that other memory management modules can reuse this part of memory resources.

[0367] Optionally, determine whether the entire ms is idle, i.e., all memory pages in the memory segment are idle. If the entire ms is idle, return the entire ms to the memory management module of the lightweight virtualization, so as to reallocate and manage this part of memory resources. Through this step, the entire memory segment can be effectively processed as idle, and the entire memory segment is returned to the upper layer memory management module, so as to better manage and utilize memory resources. This step ensures the efficiency of memory management and the rational use of resources.

[0368] In the embodiment of the present disclosure, in the memory exchange process, the to-be-allocated memory in which the compressed data of the data exchanged between the physical memory and the virtual memory is stored can be obtained, and the capacity of the to-be-allocated memory is determined. The metadata matching the capacity can be obtained as target metadata in the metadata in the structure. The position information of the to-be-allocated memory in the memory pool corresponding to the structure can be determined according to the target metadata, and the memory corresponding to the compressed data is allocated from the memory pool according to the position information, so as to realize memory allocation. In the embodiment, the compressed memory is used to reduce memory occupation and transmission overhead. In the memory exchange process, the small block of memory after compression can be more efficiently stored and transmitted, so as to improve the performance and resource utilization of the operating system, and the memory exchange and compression operation in the virtualization environment can be better supported through the small block of memory management. Through the above structured memory management manner, the effective storage and exchange of the compressed data between the physical memory and the virtual memory are ensured. Through the process of searching for the target metadata, determining the position information, and allocating the memory, the effective management and allocation of the compressed data are realized, the performance and efficiency of the operating system are improved, and the technical effect that the memory can be effectively allocated is realized, and the technical problem that the memory cannot be effectively allocated is solved.

[0369] According to the embodiment of the present disclosure, a memory allocation apparatus for implementing the memory allocation method shown in FIG. 3 is further provided.

[0370] FIG. 8 is a schematic diagram of a memory allocation apparatus according to an embodiment of the present disclosure. As shown in FIG. 8, the memory allocation apparatus 800 can include a first determining component 802, a first searching component 804, a second determining component 806, and a first allocating component 808.

[0371] The first determining component 802 is configured to determine the capacity of the to-be-allocated memory, wherein the to-be-allocated memory is used to store compressed data, and the compressed data is used to represent the compression result of the data exchanged between the physical memory and the virtual memory.

[0372] The first searching component 804 is configured to search for target metadata matching the capacity in the structure, wherein the structure at least includes metadata of different memories in the memory pool.

[0373] The second determining component 806 is configured to determine the position information of the to-be-allocated memory based on the target metadata, wherein the position information is used to represent the position of the to-be-allocated memory in the memory pool corresponding to the structure.

[0374] The first allocating component 808 is configured to allocate the memory corresponding to the compressed data from the memory pool based on the position information.

[0375] The first determining component 802, the first searching component 804, the second determining component 806 and the first allocating component 808 correspond to steps S302-S308 in the above embodiment, and have the same examples and application scenarios as the corresponding steps, but are not limited to the above embodiment. It should be noted that the above components can be hardware components or software components stored in the memory (for example, the memory 104) and processed by one or more processors (for example, the processors 102a, 102b,..., 102n), or can be a part of the apparatus and run in the computer terminal A provided in the following embodiment.

[0376] According to the embodiment of the present disclosure, a memory releasing apparatus for implementing the memory releasing method shown in FIG. 4 is further provided.

[0377] FIG. 9 is a schematic diagram of a memory releasing apparatus according to an embodiment of the present disclosure. As shown in FIG. 9, the memory releasing apparatus 900 can include a third determining component 902 and a releasing component 904.

[0378] The third determining component 902 is configured to determine, in the memory pool corresponding to the structure, the to-be-released memory, wherein the to-be-released memory is allocated from the memory pool based on position information, and is used to store compressed data, the compressed data is used to indicate a compression result of data exchanged between the physical memory and the virtual memory, the position information is used to indicate a position of the to-be-released memory in the memory pool corresponding to the structure, and the position information is determined based on target metadata, the target metadata is metadata found in the structure and matching a capacity of the to-be-released memory, and the structure at least includes metadata of different memories in the memory pool.

[0379] The releasing component 904 is configured to perform a releasing operation on the to-be-released memory.

[0380] It should be noted that the third determining component 902 and the releasing component 904 correspond to steps S402-S404 in the above embodiment, and have the same examples and application scenarios as the corresponding steps, but are not limited to the above embodiment. It should be noted that the above components can be hardware components or software components stored in the memory (for example, the memory 104) and processed by one or more processors (for example, the processors 102a, 102b,..., 102n), or can be a part of the apparatus and run in the computer terminal A provided in the following embodiment.

[0381] According to the embodiment of the present disclosure, a memory releasing apparatus for implementing the memory releasing method shown in FIG. 4 is further provided.

[0382] FIG. 10 is a schematic diagram of another memory allocation apparatus according to an embodiment of the present disclosure. As shown in FIG. 10, the memory allocation apparatus 1000 can include a fourth determining component 1002, a compression component 1004, a fifth determining component 1006, a second searching component 1008, a sixth determining component 1010, and a second allocating component 1012.

[0383] The fourth determining component 1002 is configured to determine data exchanged between the physical memory and the virtual memory.

[0384] The compression component 1004 is configured to compress the data to obtain compressed data.

[0385] The fifth determining component 1006 is configured to determine a capacity of to-be-allocated memory based on the compressed data, where the to-be-allocated memory is used to store the compressed data.

[0386] The second searching component 1008 is configured to search, in a structure, target metadata matching the capacity, where the structure includes at least metadata of different memories in a memory pool.

[0387] The sixth determining component 1010 is configured to determine location information of the to-be-allocated memory based on the target metadata, where the location information is used to represent a location of the to-be-allocated memory in a memory pool corresponding to the structure.

[0388] The second allocating component 1012 is configured to allocate, based on the location information, memory corresponding to the compressed data from the memory pool.

[0389] It should be noted that the fourth determining component 1002, the compression component 1004, the fifth determining component 1006, the second searching component 1008, the sixth determining component 1010, and the second allocating component 1012 correspond to steps S502-S512 in the above embodiment, and the six components have the same instances and application scenarios as the corresponding steps, but are not limited to the content disclosed in the above embodiment. It should be noted that the above components can be hardware components or software components stored in a memory (for example, the memory 104) and processed by one or more processors (for example, the processors 102a, 102b,..., 102n), or the above components can be a part of an apparatus and can run in the computer terminal A provided in the following embodiment.

[0390] In the memory allocation device, in the memory exchange process, the to-be-allocated memory storing compressed data of data exchanged between the physical memory and the virtual memory can be obtained, and the capacity of the to-be-allocated memory can be determined. The metadata matching the capacity can be queried as target metadata in the metadata in the structure. The position information of the to-be-allocated memory in the memory pool corresponding to the structure can be determined according to the target metadata, and the memory corresponding to the compressed data can be allocated from the memory pool according to the position information, so as to realize memory allocation. In the embodiment, the compressed memory is used to reduce memory occupation and transmission overhead. In the memory exchange process, the small block memory after compression can be more efficiently stored and transmitted, so as to improve the performance and resource utilization of the operating system, and the small block memory management can better support the memory exchange and compression operation in the virtualization environment. Through the above structured memory management manner, the effective storage and exchange of the compressed data between the physical memory and the virtual memory are ensured. Through the processes of querying the target metadata, determining the position information, and allocating the memory, the effective management and allocation of the compressed data are realized, the performance and efficiency of the operating system are improved, and the technical effect that the memory can be effectively allocated is realized, and the technical problem that the memory cannot be effectively allocated is solved.

[0391] Embodiments of the present disclosure can provide a computer terminal, which can be any one of computer terminal devices in a computer terminal group. Alternatively, in the present embodiment, the computer terminal can be replaced by a mobile terminal or other terminal device.

[0392] Alternatively, in the present embodiment, the computer terminal can be located in at least one network device of a plurality of network devices of a computer network.

[0393] In the present embodiment, the computer terminal can execute program codes for the following steps in the memory allocation method: determining the capacity of the to-be-allocated memory; querying target metadata matching the capacity in the structure; determining position information of the to-be-allocated memory based on the target metadata; and allocating memory corresponding to the compressed data from the memory pool based on the position information.

[0394] Alternatively, FIG. 11 is a structural block diagram of a computer terminal according to an embodiment of the present disclosure. As shown in FIG. 11, the computer terminal A can include one or more (only one is shown in the figure) processors 1102, a memory 1104, and a transmission device 1106.

[0395] The memory can be configured to store software programs and modules, such as program instructions / modules corresponding to the memory allocation method and device in the embodiments of the present disclosure. The processor executes the software programs and modules stored in the memory, thereby performing various functions and data processing, i.e., implementing the memory allocation method described above. The memory can include a high-speed random access memory, and can further include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some examples, the memory can further include a memory remotely arranged with respect to the processor, which can be connected to the computer terminal A through a network. Examples of the network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.

[0396] Optionally, the processor can further execute program codes of the following steps: converting the capacity into a segment number; searching for metadata satisfying the segment number in the structure; determining the searched metadata as the target metadata matching the capacity.

[0397] Optionally, the processor can further execute program codes of the following steps: determining, based on the target metadata, states of memory cells in the segment number in the memory as allocation states; determining, based on the memory cells in the allocation states, location information of the memory to be allocated.

[0398] Optionally, the processor can further execute program codes of the following steps: determining a location sequence number of the memory cells in the allocation states; determining a virtual address corresponding to the location sequence number of the memory cells; and determining the virtual address as the location information of the memory to be allocated.

[0399] Optionally, the processor can further execute program codes of the following steps: determining association information of the memory cells in the allocation states; encoding the association information to obtain an encoding result; and determining, based on the encoding result, the location information of the memory to be allocated in the memory pool.

[0400] Optionally, the processor can further execute program codes of the following steps: in response to not searching for the metadata satisfying the segment number in the structure, searching for a memory block in a memory page in an idle state from a linked list of the structure; and in response to searching for the memory block in the memory page in the idle state, determining the target metadata based on metadata corresponding to the memory page in the idle state in the structure.

[0401] Optionally, the processor can further execute program codes of the following steps: in response to searching for the memory block in the memory page in the idle state, determining a first target memory page in the idle state based on a bitmap of the metadata corresponding to the memory page in the idle state in the structure; determining a state of the first target memory page as an allocation state; and determining the target metadata based on the first target memory page in the allocation state.

[0402] Optionally, the processor can further execute program codes of the following steps: initializing the first target memory page in the allocated state; determining the metadata corresponding to the initialized first target memory page as the target metadata.

[0403] Optionally, the processor can further execute program codes of the following steps: allocating the target memory block from the memory management system in response to the failure to find the memory block in the memory page in the idle state; initializing the metadata of the target memory block to obtain the initialized metadata; determining the initialized metadata as the memory block in the memory page in the idle state found, and returning to execute the following steps: determining the target metadata based on the metadata corresponding to the memory page in the idle state in the structure in response to the memory block in the memory page in the idle state found.

[0404] Optionally, the processor can further execute program codes of the following steps: determining a plurality of memory pages recorded by the bitmap of the metadata of the target memory block; determining a second target memory page for storing the metadata of the target memory block from the plurality of memory pages; setting the bitmap corresponding to the second target memory page to obtain the initialized metadata.

[0405] Optionally, the processor can further execute program codes of the following steps: finding the memory at the position corresponding to the position information in the memory pool; determining the found memory as the memory corresponding to the compressed data.

[0406] The processor can call the information and the application program stored in the memory through the transmission device to execute the following steps: determining the to-be-released memory in the memory pool corresponding to the structure; and performing the release operation on the to-be-released memory.

[0407] Optionally, the processor can further execute program codes of the following steps: performing the parsing operation on the position information of the to-be-released memory to obtain a parsing result; and performing the release operation on the to-be-released memory based on the parsing result.

[0408] Optionally, the processor can further execute program codes of the following steps: determining the encoding result corresponding to the position information; and performing the parsing operation on the encoding result to obtain the association information.

[0409] Optionally, the processor can further execute program codes of the following steps: determining a virtual address corresponding to the to-be-released memory based on the identification information of the memory block corresponding to the to-be-released memory in the association information, and performing a release operation on the to-be-released memory from the virtual address; dequeuing the target metadata corresponding to the association information from the linked list of the structure, and in response to successful dequeuing of the target metadata from the linked list of the structure, performing a release operation on the to-be-released memory; updating the state of the memory unit of the segment quantity in the association information from an allocation state to an idle state, and in response to successful updating of the state of the memory unit of the segment quantity to the idle state, performing a release operation on the to-be-released memory.

[0410] Optionally, the processor can further execute program codes of the following steps: in response to the existence of a memory page in a non-idle state in the plurality of memory pages corresponding to the to-be-released memory in the association information, adding the memory page to the linked list of the structure; in response to the plurality of memory pages being in an idle state, releasing the memory page to an upper memory block of the memory page, and determining the state of the bitmap corresponding to the memory page to be an idle state.

[0411] The processor can call the information and the application program stored in the memory through the transmission device to execute the following steps: determining data exchanged between the physical memory and the virtual memory; compressing the data to obtain compressed data; determining a capacity of the to-be-allocated memory based on the compressed data; searching for target metadata matching the capacity in the structure; determining position information of the to-be-allocated memory based on the target metadata; and allocating memory corresponding to the compressed data from the memory pool based on the position information.

[0412] According to the embodiment of the present disclosure, a memory allocation method is provided. In the embodiment of the present disclosure, during a memory swapping process, a to-be-allocated memory storing compressed data of data to be swapped between a physical memory and a virtual memory can be obtained, and a capacity of the to-be-allocated memory can be determined. Metadata matching the capacity can be queried as target metadata in metadata in a structure. According to the target metadata, position information of the to-be-allocated memory in a memory pool corresponding to the structure can be determined, and memory corresponding to the compressed data can be allocated from the memory pool according to the position information, so as to realize memory allocation. In the embodiment, compressed memory is used to reduce memory occupation and transmission overhead. In a case where the memory swapping process needs to be frequently performed, small pieces of memory after compression can be more efficiently stored and transmitted, so as to improve performance and resource utilization of an operating system, and small piece memory management can better support memory swapping and compression operations in a virtualization environment. Through the above structured memory management manner, effective storage and swapping of compressed data between the physical memory and the virtual memory are ensured. Through the processes of querying target metadata, determining position information, and allocating memory, effective management and allocation of compressed data are realized, performance and efficiency of the operating system are improved, and a technical effect that memory can be effectively allocated is realized, and a technical problem that memory cannot be effectively allocated is solved.

[0413] Those skilled in the art can understand that the structure shown in FIG. 11 is only schematic, and the computer terminal A can also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a palm computer, a mobile Internet device (Mobile Internet Device, MID for short), a PAD, and the like. FIG. 11 does not limit the structure of the computer terminal A. For example, the computer terminal A can further include more or fewer components (such as a network interface, a display device, etc.) than those shown in FIG. 11, or have a different configuration from that shown in FIG. 11.

[0414] Those skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer readable storage medium, and the storage medium can include a flash disk, a read-only memory (Read-Only Memory, ROM for short), a random access memory (Random Access Memory, RAM for short), a magnetic disk or an optical disk, and the like.

[0415] The embodiment of the present disclosure further provides a computer readable storage medium. Optionally, in the embodiment, the computer readable storage medium can be used to save the program code executed by the memory allocation method provided in the first embodiment.

[0416] Optionally, in the embodiment, the computer readable storage medium can be located in any one of the computer terminals in the computer terminal group in the computer network, or in any one of the mobile terminals in the mobile terminal group.

[0417] Optionally, in the embodiment, the computer readable storage medium is configured to store program code for performing the following steps: determining the capacity of the memory to be allocated; searching for target metadata matching the capacity in the structure; determining location information of the memory to be allocated based on the target metadata; and allocating the memory corresponding to the compressed data from the memory pool based on the location information.

[0418] Optionally, the computer readable storage medium can further execute program code for performing the following steps: converting the capacity into the number of segments; searching for metadata satisfying the number of segments in the structure; and determining the found metadata as the target metadata matching the capacity.

[0419] Optionally, the computer readable storage medium can further execute program code for performing the following steps: determining the state of the memory units of the number of segments in the memory as an allocated state based on the target metadata; and determining the location information of the memory to be allocated based on the memory units in the allocated state.

[0420] Optionally, the computer readable storage medium can further execute program code for performing the following steps: determining the location sequence number of the memory units in the allocated state; determining a virtual address corresponding to the location sequence number of the memory units; and determining the virtual address as the location information of the memory to be allocated.

[0421] Optionally, the computer readable storage medium can further execute program code for performing the following steps: determining the association information of the memory units in the allocated state; encoding the association information to obtain an encoding result; and determining the location information of the memory to be allocated in the memory pool based on the encoding result.

[0422] Optionally, the computer readable storage medium can further execute program code for performing the following steps: in response to not finding the metadata satisfying the number of segments in the structure, searching for a memory block in a memory page in an idle state from a linked list of the structure; and in response to finding the memory block in the memory page in the idle state, determining the target metadata based on the metadata corresponding to the memory page in the idle state in the structure.

[0423] Optionally, the computer readable storage medium can further store program codes for performing the following steps: in response to finding the memory block in the memory page in the idle state, determining the first target memory page in the idle state based on the bitmap of the corresponding metadata of the first target memory page in the structure; determining the state of the first target memory page as the allocation state; and determining the target metadata based on the first target memory page in the allocation state.

[0424] Optionally, the computer readable storage medium can further store program codes for performing the following steps: initializing the first target memory page in the allocation state; and determining the initialized first target memory page as the target metadata.

[0425] Optionally, the computer readable storage medium can further store program codes for performing the following steps: in response to not finding the memory block in the memory page in the idle state, allocating the target memory block from the memory management system; initializing the metadata of the target memory block to obtain the initialized metadata; and determining the initialized metadata as the memory block in the memory page in the idle state, and returning to perform the following steps: in response to finding the memory block in the memory page in the idle state, determining the target metadata based on the corresponding metadata of the memory page in the structure in the idle state.

[0426] Optionally, the computer readable storage medium can further store program codes for performing the following steps: determining a plurality of memory pages recorded by the bitmap of the metadata of the target memory block; determining a second target memory page for storing the metadata of the target memory block in the plurality of memory pages; and setting the initialized metadata by setting the bitmap corresponding to the second target memory page.

[0427] Optionally, the computer readable storage medium can further store program codes for performing the following steps: finding the memory corresponding to the position of the position information in the memory pool; and determining the found memory as the memory corresponding to the compressed data.

[0428] As an optional example, the computer readable storage medium is configured to store program codes for performing the following steps: determining the to-be-released memory in the memory pool corresponding to the structure; and performing the release operation on the to-be-released memory.

[0429] Optionally, the computer readable storage medium can further store program codes for performing the following steps: performing the parsing operation on the position information of the to-be-released memory to obtain a parsing result; and performing the release operation on the to-be-released memory based on the parsing result.

[0430] Optionally, the computer readable storage medium can further store program codes for performing the following steps: determining the encoding result corresponding to the position information; and performing the parsing operation on the encoding result to obtain the association information.

[0431] Optionally, the computer readable storage medium can further execute program codes of the following steps: determining the virtual address corresponding to the to-be-released memory based on the identification information of the memory block corresponding to the to-be-released memory in the association information, and performing a release operation on the to-be-released memory from the virtual address; dequeuing the target metadata corresponding to the association information from the linked list of the structure, and in response to the successful dequeuing of the target metadata from the linked list of the structure, performing a release operation on the to-be-released memory; updating the state of the memory unit of the segment quantity in the association information from the allocation state to the idle state, and in response to the successful updating of the state of the memory unit of the segment quantity to the idle state, performing a release operation on the to-be-released memory.

[0432] Optionally, the computer readable storage medium can further execute program codes of the following steps: in response to the existence of the memory page in the non-idle state in the plurality of memory pages corresponding to the to-be-released memory in the association information, adding the memory page to the linked list of the structure; in response to the plurality of memory pages being in the idle state, releasing the memory page to the upper memory block of the memory page, and determining the state of the bitmap corresponding to the memory page to be the idle state.

[0433] As an optional example, the computer readable storage medium is configured to store program codes for performing the following steps: determining the data exchanged between the physical memory and the virtual memory; compressing the data to obtain compressed data; determining the capacity of the to-be-allocated memory based on the compressed data; searching for target metadata matching the capacity in the structure; determining the position information of the to-be-allocated memory based on the target metadata; and allocating the memory corresponding to the compressed data from the memory pool based on the position information.

[0434] Embodiments of the present disclosure can provide an electronic device, which can include a memory and a processor.

[0435] FIG. 12 is a block diagram of an electronic device for a memory allocation method according to an embodiment of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, tablets, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown here, their connections and relationships, and their functions, are meant to be examples only, and are not intended to limit the implementations of the present disclosure described and / or claimed in this document.

[0436] As shown in FIG. 12, the device 1200 includes a computing component 1201 that can perform various appropriate actions and processes in accordance with a computer program stored in a read-only memory (ROM) 1202 or a computer program loaded into a random access memory (RAM) 1203 from a storage component 1208. Various programs and data required by the device 1200 for operation can also be stored within the RAM 1203. The computing component 1201, the ROM 1202, and the RAM 1203 are connected to each other by a bus 1204. An input / output (I / O) interface 1205 is also connected to the bus 1204.

[0437] Various components in the device 1200 are connected to the I / O interface 1205, including an input component 1206, such as a keyboard, a mouse, etc., an output component 1204, such as various types of displays, speakers, etc., a storage component 1208, such as a magnetic disk, an optical disk, etc., and a communication component 1209, such as a network card, a modem, a wireless communication transceiver, etc. The communication component 1209 allows the device 1200 to exchange information / data with other devices over a computer network, such as the Internet, and / or various telecommunication networks.

[0438] The computing component 1201 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing component 1201 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various computing components running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The computing component 1201 performs various methods and processes described above, such as the memory allocation method. For example, in some embodiments, the memory allocation method can be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage component 1208. In some embodiments, part or all of the computer program can be loaded and / or installed onto the device 1200 via the ROM 1202 and / or the communication component 1209. When the computer program is loaded into the RAM 1203 and executed by the computing component 1201, one or more steps of the memory allocation method described above can be performed. Alternatively, in other embodiments, the computing component 1201 can be configured, by any other appropriate means (e.g., by means of firmware), to perform the memory allocation method.

[0439] According to another aspect of the embodiments of the present disclosure, a computer program product is also provided. The computer program product includes a computer program, which, when executed by a processor, implements the memory allocation method of the above-mentioned embodiments of the present disclosure.

[0440] The various embodiments of the systems and techniques described above can be implemented in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a complex programmable logic device (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.

[0441] Program code for carrying out methods of the present disclosure can be written in any combination of one or more programming languages. The program code can be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the program code, when executed by the processor or controller, produces the functions / operations specified in the flowcharts and / or the block diagrams. The program code can be executed entirely on a machine, partially on a machine, partially on a machine as a standalone software package, or entirely on a remote machine or server.

[0442] The various embodiments of the systems and techniques described above can be implemented in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (Application Specific Integrated, referred to as ASIC), an application specific standard product (Application Specific Standard Parts, referred to as ASSP), a system on a chip (System-on-a-Chip, referred to as SOC), a complex programmable logic device (Complex Programmable Logic Device, referred to as CPLD), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.

[0443] Program code for carrying out methods of the present disclosure can be written in any combination of one or more programming languages. The program code can be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the program code, when executed by the processor or controller, produces the functions / operations specified in the flowcharts and / or block diagrams. The program code can be executed entirely on a machine, partially on a machine, partially on a machine as a stand-alone software package, partially on a machine and partially on a remote machine or entirely on a remote machine or server.

[0444] In the context of the present disclosure, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include but is not limited to an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium would include one or more lines of electrical connections, portable computer disks, hard disk drives, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or Flash memory), optical fibers, compact disc read-only memories (CD-ROMs), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0445] To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having a display device (e.g., a Cathode Ray Tube (CRT) or a Liquid Crystal Display (LCD) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.

[0446] The systems and techniques described herein can be implemented in a computing system that includes a back end component, e.g., as a data server, or that includes a middleware component, e.g., an application server, or that includes a front end component, e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described herein, or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication, e.g., a communication network. Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.

[0447] The computer system can include clients and servers. The clients and the servers are generally remote from each other and typically interact through a communication network. The relationship of client and server can arise by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, a server of a distributed system, or a server combined with a blockchain.

[0448] It should be noted that the above-mentioned sequence numbers of the embodiments of the present disclosure are only for description, and do not represent the advantages and disadvantages of the embodiments.

[0449] In the above-described embodiments of the present disclosure, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.

[0450] In several embodiments provided by the present disclosure, it should be understood that the disclosed technology can be implemented in other ways. Of course, the embodiment described above is only a schematic, for example, the division of units is only a logical function division, and there can be another division manner in actual implementation, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interface, unit or module, and can be electrical or other forms.

[0451] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e., they can be located in one place, or can be distributed on a plurality of network units. According to actual needs, some or all of the units can be selected to achieve the purpose of the embodiment.

[0452] In addition, each function unit in each embodiment of the present disclosure can be integrated in one processing unit, or each unit can exist physically independently, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software function unit.

[0453] When the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such understanding, the technical solutions of the present disclosure, essentially or in the form of a part or all of the technical solutions that contribute to the prior art, or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods in the various embodiments of the present disclosure. The aforementioned storage medium includes various media that can store program codes, such as a U disk, a read-only memory, a random access memory, a mobile hard disk, a magnetic disk, or an optical disk.

[0454] The above is only the preferred embodiment of the present disclosure, and it should be noted that, for those skilled in the art, without departing from the principles of the present disclosure, some improvements and refinements can be made, and these improvements and refinements should also be considered as the protection scope of the present disclosure. Industrial applicability

[0455] The scheme provided by the embodiments of the present disclosure can be applied to the allocation process of the memory, to determine the capacity of the to-be-allocated memory, wherein the to-be-allocated memory is used to store compressed data, and the compressed data is used to represent the compression result of the data exchanged between the physical memory and the virtual memory; in a structure, target metadata matching the capacity is searched, wherein the structure at least includes metadata of different memories in a memory pool; based on the target metadata, position information of the to-be-allocated memory is determined, wherein the position information is used to represent the position of the to-be-allocated memory in the memory pool corresponding to the structure; based on the position information, the memory corresponding to the compressed data is allocated from the memory pool, thereby realizing the technical effect that the memory can be effectively allocated, and solving the technical problem that the memory cannot be effectively allocated.

Claims

A memory allocation method comprises: determining a capacity of a memory to be allocated, wherein the memory to be allocated is used to store compressed data, and the compressed data is used to represent a compression result of data exchanged between a physical memory and a virtual memory; in a structure, searching for target metadata matching the capacity, wherein the structure comprises metadata of different memories in a memory pool; based on the target metadata, determining location information of the memory to be allocated, wherein the location information is used to represent a location of the memory to be allocated in the memory pool corresponding to the structure; based on the location information, allocating memory corresponding to the compressed data from the memory pool. The method of claim 1, wherein, In the structure, searching for target metadata matching the capacity comprises: converting the capacity into a segment number, wherein the segment number is used to represent a number of memory units corresponding to the capacity, and the memory unit is used to represent a minimum memory unit allowed to be allocated in the memory; searching for metadata satisfying the segment number in the structure; determining the searched metadata as the target metadata matching the capacity. The method of claim 2, wherein, Based on the target metadata, determining the location information of the memory to be allocated comprises: based on the target metadata, determining a state of the memory units of the segment number in the memory as an allocated state; based on the memory units in the allocated state, determining the location information of the memory to be allocated. The method of claim 3, wherein, Based on the memory units in the allocated state, determining the location information of the memory to be allocated comprises: determining a location sequence number of the memory units in the allocated state; determining a virtual address corresponding to the location sequence number of the memory units; determining the virtual address as the location information of the memory to be allocated. The method of claim 3, wherein, Based on the memory units in the allocated state, determining the location information of the memory to be allocated comprises: determining association information of the memory units in the allocated state, wherein the association information is used to represent information associated with attributes of the memory units; encoding the association information to obtain an encoding result; based on the encoding result, determining the location information of the memory to be allocated in the memory pool. The method of claim 2, wherein, The method further comprises: in response to not searching for metadata satisfying the segment number in the structure, searching for a memory block in a memory page in an idle state from a linked list of the structure, wherein different nodes of the linked list are used to represent different memory blocks; in response to searching for a memory block in a memory page in the idle state, determining the target metadata based on metadata of the memory page in the idle state corresponding to the structure. The method of claim 6, wherein, In response to searching for a memory block in a memory page in the idle state, determining the target metadata based on metadata of the memory page in the idle state corresponding to the structure comprises: determining, in response to finding the memory block in the memory page in the idle state, the target metadata based on the bitmap of the metadata corresponding to the memory page in the idle state in the structure; determining the state of the first target memory page as an allocated state; determining the target metadata based on the first target memory page in the allocated state. The method of claim 7, wherein, determining the target metadata based on the first target memory page in the allocated state, comprises: initializing the first target memory page in the allocated state; determining the metadata corresponding to the initialized first target memory page as the target metadata. The method of claim 6, wherein, The method further comprises: allocating a target memory block from a memory management system in response to not finding the memory block in the memory page in the idle state; initializing the metadata of the target memory block to obtain initialized metadata; determining the initialized metadata as the memory block in the memory page in the idle state found, and returning to execute the following steps: determining the target metadata based on the metadata corresponding to the memory page in the idle state in the structure in response to finding the memory block in the memory page in the idle state. The method of claim 9, wherein, initializing the metadata of the target memory block to obtain initialized metadata, comprises: determining a plurality of memory pages recorded by the bitmap of the metadata of the target memory block; determining a second target memory page for storing the metadata of the target memory block in the plurality of memory pages; setting the bitmap corresponding to the second target memory page to obtain the initialized metadata. The method according to any one of claims 1 to 10, wherein allocating the memory corresponding to the compressed data from the memory pool based on the position information, comprises: finding the memory at the position corresponding to the position information in the memory pool; determining the found memory as the memory corresponding to the compressed data. A memory releasing method, comprising: determining a to-be-released memory in a memory pool corresponding to a structure, wherein the to-be-released memory is allocated from the memory pool based on position information and is used for storing compressed data; the compressed data is used for indicating a compression result of data exchanged between a physical memory and a virtual memory; the position information is used for indicating a position of the to-be-released memory in the memory pool corresponding to the structure, and the position information is determined based on target metadata; the target metadata is metadata found in the structure and matching a capacity of the to-be-released memory, and the structure at least comprises metadata of different memories in the memory pool; performing a releasing operation on the to-be-released memory. The method of claim 12, wherein, performing the releasing operation on the to-be-released memory, comprises: performing an analysis operation on the position information of the to-be-released memory to obtain an analysis result; performing the releasing operation on the to-be-released memory based on the analysis result. The method of claim 13, wherein, performing the analysis operation on the position information of the to-be-released memory to obtain the analysis result, comprises: determining an encoding result corresponding to the position information, wherein the encoding result is obtained by encoding association information, the association information is used to represent information associated with attributes of memory units of a number of segments in the memory, the number of segments is obtained by converting the capacity, the number of segments is used to represent a number of the memory units corresponding to the capacity, and the memory units are used to represent the smallest memory units allowed to be allocated in the memory; performing an analysis operation on the encoding result to obtain the association information, wherein the analysis result includes the association information. The method of claim 14, wherein, based on the analysis result, performing a release operation on the to-be-released memory, including at least one of the following: based on identification information of a memory block corresponding to the to-be-released memory in the association information, determining a virtual address corresponding to the to-be-released memory, and performing a release operation on the to-be-released memory from the virtual address, wherein the position information includes the virtual address; dequeueing the target metadata corresponding to the association information from the linked list of the structure, and in response to successful dequeuing of the target metadata from the linked list of the structure, performing a release operation on the to-be-released memory; updating a state of the memory units of the number of segments in the association information from an allocation state to an idle state, and in response to successful updating of the state of the memory units of the number of segments to the idle state, performing a release operation on the to-be-released memory. The method of claim 14, wherein, The method further includes: in response to the existence of a memory page in a non-idle state in a plurality of memory pages corresponding to the to-be-released memory in the association information, adding the memory page to the linked list of the structure; in response to the plurality of memory pages being in the idle state, releasing the memory page to an upper memory block of the memory page, and determining a state of a bitmap corresponding to the memory page as the idle state. A method of allocating memory, wherein, including: determining data exchanged between a physical memory and a virtual memory; performing compression on the data to obtain compressed data; based on the compressed data, determining a capacity of to-be-allocated memory, wherein the to-be-allocated memory is used to store compressed data; in a structure, finding target metadata matching the capacity, wherein the structure includes at least metadata of different memories in a memory pool; based on the target metadata, determining position information of the to-be-allocated memory, wherein the position information is used to represent a position of the to-be-allocated memory in the memory pool corresponding to the structure; based on the position information, allocating memory corresponding to the compressed data from the memory pool. A memory allocation system includes: The memory allocation end is configured to determine a capacity of to-be-allocated memory, wherein the to-be-allocated memory is used to store compressed data, and the compressed data is used to represent a compression result of data exchanged between physical memory and virtual memory; in a structure, target metadata matching the capacity is searched, wherein the structure at least includes metadata of different memories in a memory pool; based on the target metadata, position information of the to-be-allocated memory is determined, wherein the position information is used to represent a position of the to-be-allocated memory in the memory pool corresponding to the structure; and based on the position information, memory corresponding to the compressed data is allocated from the memory pool. The memory release end is configured to perform a release operation on the memory corresponding to the compressed data. An electronic device, wherein, The computer readable storage medium comprises a stored executable program, wherein when the executable program is executed, the device where the storage medium is located is controlled to execute the method in any one of claims 1 to 17. The computer readable storage medium comprises a stored executable program, wherein when the executable program is executed, the device where the storage medium is located is controlled to execute the method in any one of claims 1 to 17. The computer program is executed by the processor to implement the method in any one of claims 1 to 17. A computer-readable storage medium, wherein, ​ A computer program product, wherein, ​

Citation Information

Patent Citations

  • Memory management method and device and computing equipment

    CN111414248A

  • Memory management method and device, computer equipment and storage medium

    CN115599544A

  • Kernel large-page memory optimization method

    CN117827430A

  • Intelligent Block Allocation In A Heterogeneous Storage System

    US20220404997A1