WO2016127291A1 - Procédé et dispositif de gestion de mémoire - Google Patents
Procédé et dispositif de gestion de mémoire Download PDFInfo
- Publication number
- WO2016127291A1 WO2016127291A1 PCT/CN2015/072535 CN2015072535W WO2016127291A1 WO 2016127291 A1 WO2016127291 A1 WO 2016127291A1 CN 2015072535 W CN2015072535 W CN 2015072535W WO 2016127291 A1 WO2016127291 A1 WO 2016127291A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- memory
- length
- memory block
- pool
- block
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
Definitions
- the present invention relates to the field of information technology, and in particular, to a memory management apparatus and method.
- the Buffer Management Unit is a hardware device that is installed inside the processor and used to manage the memory.
- the method for managing the memory by the BMU is as follows: The BMU first obtains a memory of a predetermined size to be allocated, and then creates multiple memory pools according to the memory to be allocated.
- the same memory pool includes several memory blocks of equal length.
- the number of memory pools created and the length of memory blocks in each memory pool can be configured according to actual needs. For example, suppose the BMU creates three memory pools, namely memory pool 1, memory pool 2, and memory pool 3.
- the memory pool 1 includes N1 memory blocks of length L1 bytes
- the memory pool 2 includes N2 memory blocks of length L2 bytes
- the memory pool 3 includes N3 memory blocks of length L3 bytes. L1, L2 and L3 are not equal.
- the BMU manages the memory blocks in each memory pool according to the requirements of memory application and release. For example, when the required length of the memory request is L2 bytes, the BMU detects whether there is a free memory block in the memory pool 2; if it exists, selects a free memory block from the memory pool 2 for allocation and use; If it exists, the memory application fails.
- the inventor has found that the above-mentioned technologies have at least the following problems: in order to ensure the reliability of memory allocation, and to cope with the peak usage of memory blocks of different lengths, the BMU needs to separately allocate memory blocks satisfying the peak demand to each memory pool. Quantity. However, in actual use, multiple memory pools do not reach peak usage at the same time. For example, when memory pool 1 reaches the peak usage, memory pool 2 and memory pool 3 do not reach the peak usage; when memory pool 3 reaches the peak usage, memory pool 1 and memory pool 2 do not reach the peak usage. Therefore, the above technology has a problem of serious memory waste and low total memory utilization.
- the embodiment provides a memory management apparatus and method.
- the technical solution is as follows:
- a memory management device comprising:
- a first acquiring unit configured to acquire a memory of a predetermined size to be allocated
- a creating unit configured to create a shared memory pool according to the to-be-allocated memory, where the shared memory pool includes n memory blocks of a predetermined length divided by the to-be-allocated memory, where the shared memory pool is used to provide a memory application service of at least two memory blocks of different lengths, each of the at least two different lengths being less than or equal to the predetermined length, n ⁇ 2 and n being a positive integer;
- a second acquiring unit configured to acquire a required length corresponding to the memory application, where the required length is one of the at least two different lengths;
- an allocating unit configured to obtain, from the shared memory pool, a memory block of a length of the required length for allocation.
- the allocating unit is specifically configured to:
- the first memory block exists in the shared memory pool, the first memory block is allocated for use.
- the allocating unit is further configured to:
- the first memory block does not exist in the shared memory pool, select a second memory block that is idle and has a length greater than the required length from the shared memory pool;
- the allocating unit is further configured to:
- an idle second memory block having a length greater than and closest to the required length is selected from the shared memory pool.
- the device further includes:
- a third acquiring unit configured to acquire a memory address and a length corresponding to the memory block that needs to be released
- a detecting unit configured to detect, according to the memory address, whether other memory blocks in the target memory block to which the memory block to be released belongs are idle according to the memory address, when the length of the memory block to be released is less than the predetermined length,
- the length of the target memory block is one of the at least two different lengths and the length of the target memory block is greater than and closest to the length of the memory block to be released;
- a merging unit configured to merge the memory block to be released and the other memory block into the target memory block when the other memory block is idle, the length of the target memory block being the at least two different One of the lengths.
- the at least two memory blocks of different lengths include memory blocks of different lengths of w levels, and the length of the i+1th memory block is the i-th level
- the length of the memory block is q times, the length of the w-th memory block is the predetermined length, w ⁇ 2, 1 ⁇ i ⁇ w-1, q ⁇ 2 and w, i, q are integers.
- a memory management apparatus comprising: a controller and a register;
- the register is configured to store one or more instructions for implementing a memory management method
- the method includes:
- Creating a shared memory pool according to the to-be-allocated memory where the shared memory pool includes n memory blocks of a predetermined length divided by the to-be-allocated memory, where the shared memory pool is used to provide at least two different lengths. Memory application service of the memory block, each of the at least two different lengths being less than or equal to the predetermined length, n ⁇ 2 and n being a positive integer;
- the controller is operative to execute the instructions.
- the register further stores instructions for performing the following operations:
- the first memory block exists in the shared memory pool, the first memory block is allocated for use;
- the controller is also operative to execute the instructions.
- the register further stores instructions for performing the following operations:
- the controller is also operative to execute the instructions.
- the register further stores instructions for performing the following operations:
- the controller is also operative to execute the instructions.
- the register further stores instructions for performing the following operations:
- the length of the memory block to be released is less than the predetermined length, detecting, according to the memory address, whether other memory blocks in the target memory block to which the memory block to be released belongs are idle, the length of the target memory block Is one of the at least two different lengths and the length of the target memory block is greater than and closest to the length of the memory block that needs to be released;
- the other memory block If the other memory block is idle, merge the memory block to be released and the other memory block into the target memory block, and the length of the target memory block is one of the at least two different lengths ;
- the controller is also operative to execute the instructions.
- the memory block of the at least two different lengths includes a memory block of different lengths of w levels, and the length of the i+1th memory block is the i-th level
- the length of the memory block is q times, the length of the w-th memory block is the predetermined length, w ⁇ 2, 1 ⁇ i ⁇ w-1, q ⁇ 2 and w, i, q are integers.
- a memory management method comprising:
- Creating a shared memory pool according to the to-be-allocated memory where the shared memory pool includes n memory blocks of a predetermined length divided by the to-be-allocated memory, where the shared memory pool is used to provide at least two different lengths. Memory application service of the memory block, each of the at least two different lengths being less than or equal to the predetermined length, n ⁇ 2 and n being a positive integer;
- the obtaining, by using the shared memory pool, a memory block of the required length, for use includes:
- the first memory block exists in the shared memory pool, the first memory block is allocated for use.
- the detecting, in the shared memory pool, whether there is a first one that is idle and has a length of the required length After the memory block it also includes:
- the first memory block does not exist in the shared memory pool, select a second memory block that is idle and has a length greater than the required length from the shared memory pool;
- the selecting, from the shared memory pool, the second memory that is idle and has a length greater than the required length Blocks including:
- an idle second memory block having a length greater than and closest to the required length is selected from the shared memory pool.
- the method further includes:
- the length of the memory block to be released is less than the predetermined length, detecting, according to the memory address, whether other memory blocks in the target memory block to which the memory block to be released belongs are idle, the length of the target memory block Is one of the at least two different lengths and the length of the target memory block is greater than and closest to the length of the memory block that needs to be released;
- the other memory block If the other memory block is idle, merge the memory block to be released and the other memory block into the target memory block, and the length of the target memory block is one of the at least two different lengths .
- the memory block of the at least two different lengths includes a memory block of different lengths of w levels, and the length of the i+1th memory block is the i-th level
- the length of the memory block is q times, the length of the w-th memory block is the predetermined length, w ⁇ 2, 1 ⁇ i ⁇ w-1, q ⁇ 2 and w, i, q are integers.
- the shared memory pool provides at least two application services for memory blocks of different lengths, and obtains a memory block of a required length from the shared memory pool when the required length of the memory request is obtained.
- Distribute and use solve the problem of serious memory waste and low total memory utilization in related technologies; share a shared memory pool through memory blocks of different lengths, which can ensure the peak demand of different length memory blocks in memory allocation , can also achieve the effect of saving memory and improving the total utilization of memory.
- FIG. 1 is a schematic diagram of an implementation environment involved in various embodiments of the present invention.
- FIG. 2 is a block diagram showing the structure of a memory management apparatus according to an embodiment of the present invention.
- FIG. 3 is a block diagram showing the structure of a memory management apparatus according to another embodiment of the present invention.
- FIG. 4 is a schematic structural diagram of a memory management apparatus according to still another embodiment of the present invention.
- FIG. 5 is a flowchart of a method for a memory management method according to an embodiment of the present invention.
- 6A is a flowchart of a method for a memory management method according to another embodiment of the present invention.
- 6B is a schematic diagram of a memory pool created by the memory management method provided by the background technology
- FIG. 6C is a schematic diagram of a memory pool created by using the memory management method provided by the embodiment of the present invention.
- FIG. 6D is a flowchart related to step 604 in the memory management method according to another embodiment of the present invention.
- 6E is a schematic diagram of memory allocation involved in a memory management method provided by an embodiment of the present invention.
- FIGS. 7A/7B are flowcharts of a method for a memory management method according to still another embodiment of the present invention.
- FIG. 8 is a flowchart of a method for a memory management method according to still another embodiment of the present invention.
- FIG. 1 is a schematic diagram of an implementation environment involved in various embodiments of the present invention.
- the implementation environment includes: a processor (English: Central Processing Unit; CPU) 10 and a memory 20, and the processor 10 It can be connected to the memory 20 via a bus. among them:
- the processor 10 can be a single core processor or a multi-core processor.
- the processor 10 is internally provided with a memory management device 11 which is a hardware device for managing a memory, such as a BMU.
- the memory management device 11 includes a controller 11a and a register 11b. Control The controller 11a is electrically connected to the register 11b.
- the register 11b stores one or more instructions for managing the memory, the instructions being configured to be executed by the controller 11a to implement management of the memory.
- the processor 10 may further be provided with a cache Cache 12 .
- the Cache 12 is used to store storage units that are loaded from the memory 20 to meet the processor 10's need for high speed access to data.
- the memory management mode adopted by the technical solution provided by the embodiment of the present invention is a block memory management mode.
- the block memory management mode refers to dividing the memory into several memory blocks during memory initialization, and the granularity of subsequent memory application and memory release is a memory management mode of a memory block.
- Block memory management can prevent the problem of large memory fragmentation caused by repeated application and release of memory, and improve memory allocation efficiency.
- the memory management device is mainly applied to devices having high-speed access requirements for data, such as base station devices, routers, and switches, because of the above advantages of the block memory management mode. Wait.
- the base station device may be a base transceiver station (English: Base Transmitter Station, BTS for short), a base station (English: Node Base station, abbreviated as: Node B), and an evolved base station. (English: Evolved Node Base station, referred to as: eNB).
- the memory management device provided by the embodiment of the present invention may also be applied to any electronic device having data access requirements, including but not limited to a terminal device, a server, a transmission device, and the like.
- the embodiment of the invention is not limited thereto.
- FIG. 2 is a structural block diagram of a memory management apparatus according to an embodiment of the present invention.
- the memory management device can be implemented by software, hardware, or a combination of both.
- the memory management device can be disposed inside the processor for managing the memory.
- the memory management apparatus may include: a first acquisition unit 210, a creation unit 220, a second acquisition unit 230, and an allocation unit 240.
- the first obtaining unit 210 is configured to acquire a memory to be allocated of a predetermined size.
- the creating unit 220 is configured to create a shared memory pool according to the to-be-allocated memory acquired by the first obtaining unit 210.
- the shared memory pool includes n memory blocks of a predetermined length divided by the memory to be allocated, and the shared memory pool is used to provide a memory application service for at least two memory blocks of different lengths.
- Each of the at least two different lengths is less than or equal to the predetermined length, n ⁇ 2 and n is a positive integer.
- the second obtaining unit 230 is configured to obtain a required length corresponding to the memory application, where the required length is one of the at least two different lengths.
- the allocating unit 240 is configured to obtain, from the shared memory pool created by the creating unit 220, a memory block whose length is the required length acquired by the second obtaining unit 230 for allocation and use.
- the memory management apparatus provides a shared memory pool, and the application memory service of at least two different lengths is provided by the shared memory pool, and when the required length corresponding to the memory application is obtained, Obtaining a memory block of the required length from the shared memory pool for allocation; solving the problem of serious memory waste and low total memory utilization in the related art; sharing a shared memory pool through memory blocks of different lengths, It can guarantee the peak demand of different length memory blocks in memory allocation, and can save memory and improve the total utilization of memory.
- FIG. 3 is a structural block diagram of a memory management apparatus according to another embodiment of the present invention.
- the memory management device can be implemented by software, hardware, or a combination of both.
- the memory management device can be disposed inside the processor for managing the memory.
- the memory management apparatus may include: a first acquisition unit 210, a creation unit 220, a second acquisition unit 230, and an allocation unit 240.
- the first obtaining unit 210 is configured to apply, to the operating system, a memory of a predetermined size to be allocated.
- the creating unit 220 is configured to create a shared memory pool according to the to-be-allocated memory acquired by the first obtaining unit 210.
- the shared memory pool includes n memory blocks of a predetermined length divided by the memory to be allocated, and the shared memory pool is used to provide a memory application service of at least two memory blocks of different lengths, in the at least two different lengths.
- Each length is less than or equal to the above predetermined length, n ⁇ 2 and n is a positive integer.
- the at least two memory blocks of different lengths include memory blocks of different lengths of w, and the length of the i+1th memory block is q times of the length of the i-th memory block, and the The length is a predetermined length, w ⁇ 2, 1 ⁇ i ⁇ w-1, q ⁇ 2 and w, i, q are integers.
- the second obtaining unit 230 is configured to obtain a required length corresponding to the memory application, where the required length is one of the at least two different lengths.
- the allocating unit 240 is configured to obtain, from the shared memory pool created by the creating unit 220, a memory block whose length is the required length acquired by the second obtaining unit 230 for allocation and use.
- the allocating unit 240 is specifically configured to:
- the first memory block exists in the shared memory pool, the first memory block is allocated for use.
- the allocating unit 240 is specifically configured to:
- the second memory block that is free and longer than the required length is selected from the shared memory pool;
- a memory block of a required length is selected from the m memory blocks for allocation.
- the allocating unit 240 is specifically configured to:
- the second memory block having a length greater than and closest to the required length is selected from the shared memory pool.
- the device further includes: a third obtaining unit 250, a detecting unit 260, and a merging unit 270.
- the third obtaining unit 250 is configured to obtain a memory address and a length corresponding to the memory block that needs to be released.
- the detecting unit 260 is configured to detect, according to the memory address acquired by the third obtaining unit 250, whether other memory blocks in the target memory block to which the memory block to be released belongs are idle, when the length of the memory block to be released is less than a predetermined length,
- the length of the target memory block is one of the at least two different lengths described above and the length of the target memory block is greater than and closest to the length of the memory block that needs to be released.
- the merging unit 270 is configured to merge the memory block and other memory blocks that need to be released into the target memory block when the other memory blocks are idle, and the length of the target memory block is one of the at least two different lengths.
- the memory management apparatus provides a shared memory pool, and the application memory service of at least two different lengths is provided by the shared memory pool, and when the required length corresponding to the memory application is obtained, Obtaining a memory block of the required length from the shared memory pool for allocation; solving the problem of serious memory waste and low total memory utilization in the related art; sharing a shared memory pool through memory blocks of different lengths, It can guarantee the peak demand of different length memory blocks in memory allocation, and can save memory and improve the total utilization of memory.
- the memory management apparatus when there is no memory block of a required length in the shared memory pool in the memory allocation, the memory of the required length is divided by the memory block whose length is longer than the required length.
- the block is allocated, and the above-mentioned variable-length block memory allocation mode is adopted, so that the shared memory pool can provide memory application services of a plurality of block memorys of different lengths, and the allocation process is flexible. effect.
- the memory management apparatus when there are at least two second memory blocks of different lengths in the shared memory pool, also selects the idle, longer than, and closest to the required length from the shared memory pool. Two memory blocks can improve the reliability and flexibility of memory allocation to cope with subsequent different memory application requirements.
- the memory management device provided by the embodiment further combines the memory blocks with small length into the memory blocks with large lengths, and ensures that there are sufficient and large free memory blocks in the shared memory pool, so as to be different for subsequent
- the memory application requirements provide guarantees to ensure the reliability and efficiency of memory allocation.
- the memory management device provided by the foregoing embodiment performs memory management, only the division of each functional unit described above is used as an example. In actual applications, the function allocation may be completed by different functional units as needed. The internal structure of the device is divided into different functional units to complete all or part of the functions described above.
- the memory management device provided by the foregoing embodiment is the same as the method embodiment of the memory management method provided in the following embodiments. For details, refer to the method embodiment, and details are not described herein again.
- FIG. 4 is a schematic structural diagram of a memory management apparatus according to still another embodiment of the present invention.
- the memory management device 400 may be a hardware device, such as a BMU, disposed inside the processor for managing the memory.
- the memory management device 400 can include a controller 410 and a register 420. among them:
- the register 420 is configured to store one or more instructions for implementing a memory management method, the instruction comprising:
- the shared memory pool includes n memory blocks of a predetermined length divided by the memory to be allocated, and the shared memory pool is used for providing memory requests of at least two memory blocks of different lengths Serving, each of the at least two different lengths being less than or equal to the predetermined length, n ⁇ 2 and n being a positive integer;
- the controller 410 is configured to execute the above instructions.
- the memory management apparatus provides a shared memory pool, and the application memory service of at least two different lengths is provided by the shared memory pool, and when the required length corresponding to the memory application is obtained, Obtaining a memory block of the required length from the shared memory pool for allocation; solving the problem of serious memory waste and low total memory utilization in the related art; sharing a shared memory pool through memory blocks of different lengths, It can guarantee the peak demand of different length memory blocks in memory allocation, and can save memory and improve the total utilization of memory.
- the register 420 also stores instructions for performing the following operations:
- the first memory block exists in the shared memory pool, the first memory block is allocated for use;
- the controller 410 is also operative to execute the above instructions.
- the register 420 also stores instructions for performing the following operations:
- the controller 410 is also operative to execute the above instructions.
- the register 420 also stores instructions for performing the following operations:
- the controller 410 is also operative to execute the above instructions.
- the register 420 also stores instructions for performing the following operations:
- the length of the memory block to be released is less than a predetermined length, detecting, according to the memory address, whether other memory blocks in the target memory block to which the memory block to be released belongs are free, and the length of the target memory block is at least two different lengths. And the length of the target memory block is greater than and closest to the length of the memory block that needs to be released;
- the memory blocks and other memory blocks that need to be released are merged into the target memory block, and the length of the target memory block is one of the at least two different lengths;
- the controller 410 is also operative to execute the above instructions.
- the at least two different lengths of memory blocks include w-level memory blocks of different lengths, and the length of the i+1th-level memory block is the i-th memory block. q times the length, the length of the w-th memory block is a predetermined length, w ⁇ 2, 1 ⁇ i ⁇ w-1, q ⁇ 2 and w, i, q are integers.
- the memory management apparatus allocates a length to a memory block of a length greater than a required length when a memory block of a required length does not exist in the shared memory pool during memory allocation.
- the length of the memory block is allocated, and the above-mentioned variable-length block memory allocation mode is adopted, so that the shared memory pool can provide memory application services of a plurality of different lengths of block memory, and the allocation process is flexible and efficient.
- the memory management apparatus when there are at least two second memory blocks of different lengths in the shared memory pool, also selects the idle, longer than, and closest to the required length from the shared memory pool. Two memory blocks can improve the reliability and flexibility of memory allocation to cope with subsequent different memory application requirements.
- the memory management device provided by the embodiment further combines the memory blocks with small length into the memory blocks with large lengths, and ensures that there are sufficient and large free memory blocks in the shared memory pool, so as to be different for subsequent
- the memory application requirements provide guarantees to ensure the reliability and efficiency of memory allocation.
- FIG. 5 is a flowchart of a method for a memory management method according to an embodiment of the present invention.
- the memory management method is applied to the memory management device in the implementation environment shown in FIG. 1, and the memory management device may be a BMU provided inside the processor.
- the memory management method can include the following steps:
- Step 502 Acquire a memory of a predetermined size to be allocated.
- Step 504 Create a shared memory pool according to the to-be-allocated memory, where the shared memory pool includes n memory blocks of a predetermined length divided by the memory to be allocated, and the shared memory pool is used to provide at least two memory blocks of different lengths.
- the memory application service each of the at least two different lengths being less than or equal to the predetermined length, n ⁇ 2 and n being a positive integer.
- Step 506 Acquire a required length corresponding to the memory application, where the required length is one of the at least two different lengths.
- Step 508 Obtain a memory block with a length of the required length from the shared memory pool for allocation.
- the memory management method provided in this embodiment provides a shared memory pool, and the application memory service of at least two different lengths is provided by the shared memory pool, and when the required length corresponding to the memory application is obtained, Obtaining a memory block of the required length from the shared memory pool for allocation; solving the problem of serious memory waste and low total memory utilization in the related art; sharing a shared memory pool through memory blocks of different lengths, It can guarantee the peak demand of different length memory blocks in memory allocation, and can save memory and improve the total utilization of memory.
- FIG. 6A is a flowchart of a method for a memory management method according to another embodiment of the present invention.
- the memory management method is applied to the memory management device in the implementation environment shown in FIG. 1, and the memory management device may be a BMU provided inside the processor.
- the memory management method can include the following steps:
- Step 601 Acquire a memory of a predetermined size to be allocated.
- the memory management device initializes the memory through steps 601 and 602.
- the memory management device itself requests a predetermined size of memory to be allocated to the operating system, or applies a predetermined size of memory to be allocated to the operating system through software.
- the predetermined size may be an empirical value preset according to actual needs. For example, the predetermined size may be set in advance according to the peak usage of the memory blocks of various lengths required for the memory application; and/or the predetermined size may also be set in advance according to the size of the physical memory managed by the operating system.
- the predetermined size corresponding to the memory to be allocated provided by the operating system to the memory management device is smaller than the size of the physical memory managed by the operating system.
- the size of the physical memory managed by the operating system is M
- the operating system can provide the memory of size N to the memory management device as an allocatable memory, where M>N.
- the M-N memory reserved by the operating system is the memory required for the operating system to operate normally.
- Step 602 Create a shared memory pool according to the memory to be allocated.
- the memory management device creates a shared memory pool according to the memory to be allocated obtained by the application.
- the shared memory pool includes n memory blocks of a predetermined length divided by the memory to be allocated, n ⁇ 2 and n is a positive integer.
- the shared memory pool is used to provide memory for at least two memory blocks of different lengths To apply for a service, each of the at least two different lengths is less than or equal to the predetermined length. For example, when the predetermined length is 4X, the shared memory pool can provide memory application services for memory blocks of different lengths such as X, 2X, and 4X. For another example, when the predetermined length is 5X, the shared memory pool can provide memory application services for memory blocks of different lengths such as X, 2X, 3X, 4X, and 5X.
- the memory management device when the memory management device needs to provide a memory application service of a memory block of different lengths, it needs to create w Memory pool, w ⁇ 2 and w is an integer.
- w Memory pool w ⁇ 2 and w is an integer.
- FIG. 6B if the memory management method provided by the background technology is used, when the memory management device needs to provide a memory application service of three different lengths of memory blocks of length X, 2X, and 4X, it needs to be created.
- 3 memory pools such as memory pool 1, memory pool 2, and memory pool 3 in Figure 6B.
- the memory pool 1 includes n 1 memory blocks of length X
- the memory pool 2 includes n 2 memory blocks of length 2X
- the memory pool 3 includes n 3 memory blocks of length 4X.
- the memory management device when the memory management device needs to provide the memory application service of the memory blocks of different lengths, it only needs to create a shared memory pool, w ⁇ 2 and w is an integer.
- the memory management device creates a shared memory pool in which the memory management device creates a memory application service with memory modules of different lengths of X, 2X, and 4X. Includes n memory blocks of length 4X.
- the memory management device when the memory management device needs to provide a memory application service for a plurality of memory blocks of different lengths, the memory management device can present multiple memory pools externally, and only one memory pool needs to be maintained in the pair.
- Step 603 Acquire a required length corresponding to the memory application.
- the memory management device provides memory application services of different lengths of block memory to external software and/or hardware.
- the external software and/or hardware may apply to the memory management device for a memory block of a required length; correspondingly, the memory management device obtains the required length corresponding to the memory application.
- the required length is one of the above two different lengths.
- the memory management device can externally present three memory pools, which are assumed to be Pool A, Pool B, and Pool C, respectively.
- Pool A corresponds to a memory block of length X
- Pool B corresponds to a memory block of length 2X
- Pool C corresponds to a memory block of length 4X.
- the memory management device can be based on the outside The memory pool accessed by the software and/or hardware determines the length of the request for the memory request.
- Step 604 Obtain a memory block of the length of the required length from the shared memory pool for allocation.
- the memory management device Since only one shared memory pool is maintained in the memory management device, when the memory management device obtains the required length, regardless of the required length, the memory management device obtains a memory block of a required length from the shared memory pool. Assigned for use.
- this step may include the following sub-steps:
- Step 604a Detect whether there is a first memory block that is idle and has a length of required length in the shared memory pool.
- the memory management device can use different identifiers to distinguish whether the memory block is free.
- the memory management device obtains the required length corresponding to the memory application, it detects whether there is a first memory block that is free and has a length of required length in the shared memory pool. Referring to FIG. 6C, for example, when the required length is X, the memory management device detects whether there is a free memory block of length X in the shared memory pool; for example, when the required length is 2X, the memory management device detects the shared memory. Whether there is a free 2X memory block in the pool, and so on.
- step 604b If the first memory block exists in the shared memory pool, the following step 604b is performed; otherwise, the following steps 604c to 604e are performed.
- step 604b the first memory block is allocated for use.
- the memory management device allocates the first memory block.
- the memory management device selects one of the first memory blocks for allocation and use.
- Step 604c Select, from the shared memory pool, a second memory block that is idle and has a length greater than a required length.
- the memory management device selects a second memory block that is free and longer than the required length from the shared memory pool.
- the memory management device detects whether there is free and 2X or 4X in the shared memory pool. For example, when the required length is 2X, and there is no free memory block with a length of 2X in the shared memory pool, the memory management device detects whether there is a free memory block of 4X in the shared memory pool. And so on.
- the memory management device may perform the following steps before performing step 604c above: When there is no idle memory module of the required length in the shared memory pool, it is detected whether there is a second memory block that is free and longer than the required length in the shared memory pool; if there is a requirement in the shared memory pool that meets the above requirements The second memory block executes step 604c above; otherwise, the response to the memory allocation failure is fed back.
- the reason that the second memory block that meets the foregoing requirement does not exist in the shared memory pool may include: the required length is the maximum length of the memory block that the shared memory pool can provide, and there is no idle in the shared memory pool. And the length is the first memory block of the required length; or, the shared memory pool has a memory block whose length is longer than the required length, but these memory blocks are in use.
- Step 604d the second memory block is divided into m memory blocks, where the m memory blocks include memory blocks of a required length, m ⁇ 2 and m is an integer.
- the memory management device divides the selected second memory block into m memory blocks, and the m memory blocks include at least one memory block of a required length. For example, referring to FIGS. 6C and 6E, it is assumed that there are n memory blocks of length 4X in the shared memory pool after initializing the configuration. When the required length of the first memory application is X, the memory management device may select a memory block of length 4X and divide it into three memory blocks (including two memory blocks 61 of length X, 62 and 1 memory block 63) of length 2X.
- Step 604e Select a memory block of a required length from the m memory blocks for allocation and use.
- the memory management device selects a memory block of a required length from the divided m memory blocks for allocation.
- the memory management device selects a memory block whose length is a required length. For example, for the first memory application of the above example, the memory management device selects one memory block of length X from the three memory blocks obtained by the partitioning (the memory of length X shown by the oblique line in FIG. 6E). Block 61).
- the memory management device can detect that there is a free memory block with a length of 2X in the shared memory pool, and allocate the memory block of length 2X. (The memory block 63 having a length of 2X as indicated by a hatched line in Fig. 6E).
- the memory management device selects, from the shared memory pool, the second, the length that is greater than and closest to the required length.
- Memory block For example, when the demand length is X and the second memory block of length 2X and 4X exists in the shared memory pool, the memory management device selects the second memory block of length 2X.
- the shared memory pool still has an idle 2X memory block and a free 4X memory block.
- the memory management device selects a memory block of length 4X for division (assuming that it is divided into two memory blocks of length X and one memory block of length 2X), the remaining free memory in the shared memory pool after this allocation
- the memory block includes one memory block of length X and two memory blocks of length 2X.
- the shared memory pool cannot continue to provide a memory block of length 4X.
- the memory management device selects a memory block of length 2X for partitioning (assuming that it is divided into two memory blocks of length X)
- the remaining free memory blocks in the shared memory pool after the allocation include one length X.
- the memory block and a memory block of length 4X then the shared memory pool can continue to provide memory blocks of length X, 2X or 4X without other memory blocks being released.
- At least two different lengths of memory blocks provided by the memory management device may include memory blocks of different lengths of w levels.
- the length of the i+1th-level memory block is q times the length of the i-th memory block, and the length of the w-th memory block is the predetermined length, w ⁇ 2, 1 ⁇ i ⁇ w-1, q ⁇ 2 And w, i, q are integers.
- the at least two different lengths mentioned above include: X, 2X, 4X, 8X, and the like.
- the at least two different lengths described above include X, 3X, 9X, and the like.
- the lengths between adjacent levels of memory blocks may not have the same multiple relationship.
- the at least two different lengths mentioned above include: X, 4X, 7X, and the like.
- X X
- 4X 4X
- 7X 7X
- the lengths of the adjacent memory blocks have the same multiple relationship, which makes the shared memory pool more reasonable and flexible when partitioning the memory blocks, and prevents memory fragmentation. Subsequent different memory application requirements.
- a shared memory pool is shared by memory blocks of different lengths, which can ensure the peak demand of different length memory blocks in memory allocation, and can save memory and improve the total utilization of memory.
- the memory management device needs to provide a memory application service of a memory block of different lengths. If the memory management method provided by the background technology is used, at least the memory size to be allocated to the operating system is required.
- L k represents the length of the kth length of the memory block
- n k represents the peak demand quantity of the kth length of the memory block
- w ⁇ 2 and w is an integer.
- the size N of the memory to be allocated that the memory management device applies to the operating system is:
- the memory management device only needs to apply for the memory to be allocated with the size of 4XY ⁇ 5XY to the operating system, so as to ensure that the memory allocation can cope with the peak demand of the memory blocks of different lengths. . It can be seen that, compared with the memory management method provided by the background technology, the memory management method provided in this embodiment can save about 30% to 40% of memory under the premise of ensuring the same memory allocation requirement. Especially for embedded systems, it can fully meet the memory capacity and cost requirements of embedded systems.
- the memory management method provided in this embodiment provides a shared memory pool, and the application memory service of at least two different lengths is provided by the shared memory pool, and when the required length corresponding to the memory application is obtained, Obtaining a memory block of the required length from the shared memory pool for allocation; solving the problem of serious memory waste and low total memory utilization in the related art; sharing a shared memory pool through memory blocks of different lengths, It can guarantee the peak demand of different length memory blocks in memory allocation, and can save memory and improve the total utilization of memory.
- the memory block of the required length is divided into the memory blocks of the length longer than the required length.
- the allocation is performed by using the above-mentioned variable-length block memory allocation method, so that the shared memory pool can provide memory application services of a plurality of block memorys of different lengths, and the allocation process is flexible and efficient.
- the memory management method provided in this embodiment when there are at least two second memory blocks of different lengths in the shared memory pool, also selects the idle, longer than, and closest to the required length from the shared memory pool. Two memory blocks can improve the reliability and flexibility of memory allocation to cope with subsequent different memory application requirements.
- FIG. 7A/7B is a flowchart of a method for a memory management method according to still another embodiment of the present invention.
- the above step 604a of the embodiment shown in FIG. 6A may include the following sub-steps:
- Step 604a1 Detect whether a first memory block exists in a specified memory block set of the shared memory pool.
- Step 604a2 if present, selects the first memory block from the specified set of memory blocks for allocation use.
- the specified memory block set includes at least one memory block, and the memory block included in the specified memory block set is used to be preferentially selected in the memory allocation.
- the memory block included in the specified memory block set can be pre-selected, for example, after the shared memory pool is created, several memory blocks are selected, and after the creation of the shared memory pool, a number of memory blocks are selected at the end.
- the memory blocks included in the specified memory block set can also be determined during the memory allocation process, such as controlling a number of memory blocks to be preferentially selected by means of a stack.
- the memory management apparatus detects whether there is a first memory block that is free and has a length of a required length in the specified memory block set.
- the memory management device preferentially selects a first memory block from the specified memory block set for allocation.
- the memory management device allows a certain portion of the memory block to be used at a high frequency by precisely controlling the allocation of the memory block, which is advantageous for improving the read hit rate and system performance.
- step 604c of the embodiment shown in FIG. 6A may include the following sub-steps:
- Step 604c1 Detect whether a second memory block exists in the specified memory block set of the shared memory pool.
- Step 604c2 if present, selects a second memory block from the specified set of memory blocks for allocation.
- the memory management apparatus detects whether there is a second memory block that is idle and has a length greater than the required length in the specified memory block set. .
- the memory management device preferentially selects a second memory block from the specified memory block set for allocation.
- the memory management device allows a certain portion of the memory block to be used at a high frequency by precisely controlling the allocation of the memory block, which is advantageous for improving the read hit rate and system performance.
- the memory management device acquires a second memory block that satisfies the above requirement from other memory blocks in the shared memory pool for allocation.
- the memory management device can obtain a first one that satisfies the above requirements from other memory blocks in the shared memory pool.
- the memory block is allocated for use; or the memory management device can perform the above Step 604c1 is not specifically limited in this embodiment.
- the memory management method provided by the embodiment improves the read hit rate and the system by accurately controlling the allocation and use of the memory block when the memory is allocated, so that a certain portion of the memory block is used at a high frequency. performance.
- FIG. 8 is a flowchart of a method for a memory management method according to still another embodiment of the present invention.
- the method further includes:
- Step 605 Acquire a memory address and a length corresponding to the memory block that needs to be released.
- the memory management device obtains the memory address and length corresponding to the memory block that needs to be released.
- the memory address is used to identify and distinguish different memory blocks, and different memory blocks correspond to different memory addresses.
- Step 606 When the length of the memory block to be released is less than a predetermined length, detect, according to the memory address, whether other memory blocks in the target memory block to which the memory block to be released belongs are idle.
- the length of the target memory block is one of the at least two different lengths, and the length of the target memory block is greater than and closest to the length of the memory block that needs to be released.
- Step 607 If other memory blocks are idle, merge the memory blocks and other memory blocks that need to be released into the target memory block.
- the memory management device detects whether other memory blocks in the target memory block to which it belongs are free according to the memory address of the memory block 61.
- the target memory block is a memory block of length 2X composed of the memory block 61 and the memory block 62. If the memory management device detects that the memory block 62 is free, the memory management device combines the memory block 61 and the memory block 62 into a memory block of length 2X. Further, if the memory management device detects that the memory block 62 is in use, the flow is terminated.
- the memory management device can continue to detect whether the target memory block and other memory blocks can be merged into a higher-level (that is, a longer-length) memory block; if so, continue The memory block merging step is performed until a memory block of the above predetermined length is obtained. For example, in FIG. 6E, if the memory block 63 is also idle, the memory management apparatus may further merge the memory block 63 of the length 2X obtained by the combination into the memory block 63 into a memory block of length 4X.
- the flow is ended. Since the predetermined length is the maximum length of the memory block that the shared memory pool can provide, the length of the memory block that needs to be freed When equal to the predetermined length, the memory management device does not need to perform the memory block merging step.
- the memory management method provided in this embodiment also combines a memory block with a small length into a memory block with a large length, and tries to ensure that there are sufficient and large free memory blocks in the shared memory pool, so as to Subsequent different memory application requirements provide guarantees to ensure the reliability and efficiency of memory allocation.
- the memory management apparatus provided in any of the embodiments of FIG. 2 to FIG. 4 can perform the memory management method provided in any of the embodiments of FIG. 5, FIG. 6A, FIG. 7A, FIG. 7B, and FIG.
- the specific functions and workflows of the various units or components may be referred to in the related parts of the method embodiments, and the descriptions of the various embodiments provided by the present invention may also be referred to each other.
- a person skilled in the art may understand that all or part of the steps of implementing the above embodiments may be completed by hardware, or may be instructed by a program to execute related hardware, and the program may be stored in a computer readable storage medium.
- the storage medium mentioned may be a read only memory, a magnetic disk or an optical disk or the like.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Memory System (AREA)
Abstract
Un procédé et un dispositif de gestion de mémoire, qui concerne le domaine technique des informations. Le procédé comprend les étapes consistant à : acquérir une mémoire qui doit être allouée et est d'une taille prédéterminée (S502); créer un pool de mémoire partagé selon la mémoire qui doit être allouée, avec le pool de mémoire partagé comprenant n blocs de mémoire dont la longueur est prédéterminée et qui sont obtenus en divisant la mémoire à être allouée, et le pool de mémoire partagé est utilisé pour un service d'application de mémoire pour fournir des blocs de mémoire d'au moins deux longueurs différentes (S504); acquérir une longueur demandée correspondant à une application de mémoire (S506); et acquérir, à partir du pool de mémoire partagé, un bloc de mémoire dont la longueur est la longueur demandée pour une utilisation dans l'allocation (S508). La solution technique résout les problèmes dans l'état atuel d'un gaspillage important de mémoire et d'un faible taux total d'utilisation de la mémoire. Les blocs de mémoire de différentes longueurs partagent un pool de mémoire partagé, de telle sorte qu'il n'est pas uniquement garanti que les pics de demande des blocs de mémoire de différentes longueurs soient pris en compte lorsqu'une mémoire est attribuée, mais également les effets d'économie de mémoire et d'amélioration du taux total d'utilisation de la mémoire peuvent être obtenus.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
PCT/CN2015/072535 WO2016127291A1 (fr) | 2015-02-09 | 2015-02-09 | Procédé et dispositif de gestion de mémoire |
CN201580075454.8A CN107209716B (zh) | 2015-02-09 | 2015-02-09 | 内存管理装置和方法 |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
PCT/CN2015/072535 WO2016127291A1 (fr) | 2015-02-09 | 2015-02-09 | Procédé et dispositif de gestion de mémoire |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2016127291A1 true WO2016127291A1 (fr) | 2016-08-18 |
Family
ID=56614242
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2015/072535 WO2016127291A1 (fr) | 2015-02-09 | 2015-02-09 | Procédé et dispositif de gestion de mémoire |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN107209716B (fr) |
WO (1) | WO2016127291A1 (fr) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110008021A (zh) * | 2019-03-05 | 2019-07-12 | 平安科技(深圳)有限公司 | 内存管理方法、装置、电子设备及计算机可读存储介质 |
CN110427273A (zh) * | 2019-06-25 | 2019-11-08 | 平安科技(深圳)有限公司 | 内存调度方法、装置、设备及存储介质 |
CN111143064A (zh) * | 2019-12-25 | 2020-05-12 | 浙江中控技术股份有限公司 | 一种处理内存的方法及系统 |
CN111796902A (zh) * | 2019-04-08 | 2020-10-20 | 维塔科技(北京)有限公司 | 切换共享内存区的方法和装置、存储介质和电子设备 |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107766153A (zh) * | 2017-10-17 | 2018-03-06 | 华为技术有限公司 | 一种内存管理方法及装置 |
CN110858162B (zh) * | 2018-08-24 | 2022-09-23 | 华为技术有限公司 | 内存管理方法及装置、服务器 |
CN110287127A (zh) * | 2019-05-14 | 2019-09-27 | 江苏大学 | 一种多粒度多核可扩展的非易失性内存管理方法及系统 |
CN113467930B (zh) * | 2021-05-31 | 2023-04-14 | 翱捷科技股份有限公司 | 一种硬件管理共享内存的处理方法及装置 |
CN114296917A (zh) * | 2021-12-23 | 2022-04-08 | 中汽创智科技有限公司 | 一种内存分配方法、装置、自适应汽车开放系统架构 |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102650931A (zh) * | 2012-04-01 | 2012-08-29 | 华为技术有限公司 | 一种写入数据的方法及系统 |
CN103077126A (zh) * | 2012-12-24 | 2013-05-01 | 中兴通讯股份有限公司 | 一种内存管理方法和装置 |
CN103425592A (zh) * | 2013-08-05 | 2013-12-04 | 大唐移动通信设备有限公司 | 一种多进程系统中的内存管理方法及装置 |
CN103838859A (zh) * | 2014-03-19 | 2014-06-04 | 厦门雅迅网络股份有限公司 | 一种减少linux下多进程间数据拷贝的方法 |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1181434C (zh) * | 2001-06-28 | 2004-12-22 | 华为技术有限公司 | 自适应动态内存管理方法 |
CN101329655B (zh) * | 2008-07-31 | 2011-09-28 | 北京天碁科技有限公司 | 一种内存管理方法和内存管理装置 |
CN101673246A (zh) * | 2009-08-06 | 2010-03-17 | 深圳市融创天下科技发展有限公司 | 一种高效的先进先出数据池读写方法 |
CN102455974A (zh) * | 2010-10-21 | 2012-05-16 | 上海宝信软件股份有限公司 | 一种内存消耗可控的高速内存申请释放管理系统及方法 |
CN102063385A (zh) * | 2010-12-23 | 2011-05-18 | 深圳市金宏威实业发展有限公司 | 一种内存管理方法和系统 |
-
2015
- 2015-02-09 CN CN201580075454.8A patent/CN107209716B/zh active Active
- 2015-02-09 WO PCT/CN2015/072535 patent/WO2016127291A1/fr active Application Filing
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102650931A (zh) * | 2012-04-01 | 2012-08-29 | 华为技术有限公司 | 一种写入数据的方法及系统 |
CN103077126A (zh) * | 2012-12-24 | 2013-05-01 | 中兴通讯股份有限公司 | 一种内存管理方法和装置 |
CN103425592A (zh) * | 2013-08-05 | 2013-12-04 | 大唐移动通信设备有限公司 | 一种多进程系统中的内存管理方法及装置 |
CN103838859A (zh) * | 2014-03-19 | 2014-06-04 | 厦门雅迅网络股份有限公司 | 一种减少linux下多进程间数据拷贝的方法 |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110008021A (zh) * | 2019-03-05 | 2019-07-12 | 平安科技(深圳)有限公司 | 内存管理方法、装置、电子设备及计算机可读存储介质 |
CN110008021B (zh) * | 2019-03-05 | 2024-05-28 | 平安科技(深圳)有限公司 | 内存管理方法、装置、电子设备及计算机可读存储介质 |
CN111796902A (zh) * | 2019-04-08 | 2020-10-20 | 维塔科技(北京)有限公司 | 切换共享内存区的方法和装置、存储介质和电子设备 |
CN111796902B (zh) * | 2019-04-08 | 2024-03-19 | 维塔科技(北京)有限公司 | 切换共享内存区的方法和装置、存储介质和电子设备 |
CN110427273A (zh) * | 2019-06-25 | 2019-11-08 | 平安科技(深圳)有限公司 | 内存调度方法、装置、设备及存储介质 |
CN111143064A (zh) * | 2019-12-25 | 2020-05-12 | 浙江中控技术股份有限公司 | 一种处理内存的方法及系统 |
Also Published As
Publication number | Publication date |
---|---|
CN107209716A (zh) | 2017-09-26 |
CN107209716B (zh) | 2020-04-21 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2016127291A1 (fr) | Procédé et dispositif de gestion de mémoire | |
US8478926B1 (en) | Co-processing acceleration method, apparatus, and system | |
EP3796168A1 (fr) | Appareil de traitement d'informations, procédé de traitement d'informations et programme de gestion de connexion de machine virtuelle | |
US7840775B2 (en) | Storage system in which resources are dynamically allocated to logical partition, and logical division method for storage system | |
US9081504B2 (en) | Write bandwidth management for flash devices | |
CN110196770B (zh) | 云系统内存数据处理方法、装置、设备及存储介质 | |
US20120192186A1 (en) | Computing Platform with Resource Constraint Negotiation | |
US20130086352A1 (en) | Dynamically configurable storage device | |
CN111104219A (zh) | 虚拟核心与物理核心的绑定方法、装置、设备及存储介质 | |
US20110161965A1 (en) | Job allocation method and apparatus for a multi-core processor | |
JP7506096B2 (ja) | 計算資源の動的割り当て | |
KR20130106392A (ko) | 다수의 메모리 채널들을 가진 컴퓨팅 시스템에서의 메모리 버퍼들의 할당 | |
KR101140914B1 (ko) | 컴퓨팅 자원들을 제어하는 기술 | |
US20220253252A1 (en) | Data processing method and apparatus | |
KR20180089273A (ko) | 비순차적 리소스 할당을 구현하는 방법 및 장치 | |
US9697047B2 (en) | Cooperation of hoarding memory allocators in a multi-process system | |
US20110153971A1 (en) | Data Processing System Memory Allocation | |
KR20170055180A (ko) | 멀티 운영시스템을 지닌 전자장치 및 이의 동적 메모리 관리 방법 | |
WO2020259208A1 (fr) | Procédé et appareil de programmation de mémoire, dispositif et support d'informations | |
CN112162818B (zh) | 一种虚拟内存分配方法、装置、电子设备及存储介质 | |
US20080005404A1 (en) | Method for managing buffers pool and a system using the method | |
CN105677481A (zh) | 一种数据处理方法、系统及电子设备 | |
CN104750614A (zh) | 用于管理存储器的方法和装置 | |
CN109167740B (zh) | 一种数据传输的方法和装置 | |
US20130247065A1 (en) | Apparatus and method for executing multi-operating systems |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 15881453 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 15881453 Country of ref document: EP Kind code of ref document: A1 |