WO2016127291A1 - Memory management device and method - Google Patents

Memory management device and method Download PDF

Info

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
Application number
PCT/CN2015/072535
Other languages
French (fr)
Chinese (zh)
Inventor
洪涛
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to PCT/CN2015/072535 priority Critical patent/WO2016127291A1/en
Priority to CN201580075454.8A priority patent/CN107209716B/en
Publication of WO2016127291A1 publication Critical patent/WO2016127291A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing 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

A memory management device and method, which relate to the technical field of information. The method comprises: acquiring a memory which is to be allocated and is of a predetermined size (S502); creating a shared memory pool according to the memory to be allocated, with the shared memory pool comprising n memory blocks of which the length is a predetermined length and which are obtained by dividing the memory to be allocated, and the shared memory pool being used for a memory application service for providing memory blocks of at least two different lengths (S504); acquiring a demanded length corresponding to a memory application (S506); and acquiring, from the shared memory pool, a memory block of which the length is the demanded length for use in allocation (S508). The technical solution solves the problems in the related art of a serious waste of a memory and a low total utilization rate of the memory. Memory blocks of different lengths share a shared memory pool, so that it cannot only be guaranteed that peak demands of the memory blocks of different lengths are coped with when a memory is allocated, but also the effects of saving a memory and improving a total utilization rate of the memory can be achieved.

Description

内存管理装置和方法Memory management device and method 技术领域Technical field
本发明涉及信息技术领域,特别涉及一种内存管理装置和方法。The present invention relates to the field of information technology, and in particular, to a memory management apparatus and method.
背景技术Background technique
缓冲器管理单元(英文:Buffer Management Unit;简称:BMU)是一个设置于处理器内部、用于对内存进行管理的硬件装置。The Buffer Management Unit (BMU) is a hardware device that is installed inside the processor and used to manage the memory.
BMU管理内存的方法为:BMU首先获取预定大小的待分配内存,然后根据上述待分配内存创建多个内存池,同一内存池中包含若干个长度相等的内存块。其中,内存池的创建数量,以及各个内存池中内存块的长度均可根据实际需求进行配置。比如,假设BMU创建了3个内存池,分别为内存池1、内存池2和内存池3。其中,内存池1中包含N1个长度为L1字节的内存块,内存池2中包含N2个长度为L2字节的内存块,内存池3中包含N3个长度为L3字节的内存块,L1、L2和L3两两均不相等。之后,BMU根据内存申请和释放的需要,对各个内存池中的内存块进行管理。比如,当内存申请所对应的需求长度为L2字节时,BMU检测内存池2中是否存在空闲的内存块;若存在,则从内存池2中选取一个空闲的内存块进行分配使用;若不存在,则内存申请失败。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, and the memory pool 2 includes N2 memory blocks of length L2 bytes, and the memory pool 3 includes N3 memory blocks of length L3 bytes. L1, L2 and L3 are not equal. After that, 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.
在实现本发明的过程中,发明人发现上述技术至少存在以下问题:为了保证内存分配的可靠性,应对不同长度内存块的使用峰值,BMU需要分别给各个内存池配置满足使用峰值需求的内存块数量。然而,在实际使用中,多个内存池并不会同时达到使用峰值。比如,当内存池1达到使用峰值时,内存池2和内存池3未达到使用峰值;当内存池3达到使用峰值时,内存池1和内存池2未达到使用峰值。因此,上述技术存在内存浪费严重,内存的总利用率低的问题。In the process of implementing the present invention, 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.
发明内容Summary of the invention
为了解决上述技术存在的内存浪费严重,内存的总利用率低的问题,本发 明实施例提供了一种内存管理装置和方法。所述技术方案如下:In order to solve the problem of serious memory waste and low total memory utilization in the above technology, this issue The embodiment provides a memory management apparatus and method. The technical solution is as follows:
第一方面,提供了一种内存管理装置,所述装置包括:In a first aspect, a memory management device is provided, the device comprising:
第一获取单元,用于获取预定大小的待分配内存;a first acquiring unit, configured to acquire a memory of a predetermined size to be allocated;
创建单元,用于根据所述待分配内存创建共享内存池,所述共享内存池中包括将所述待分配内存划分得到的n个长度为预定长度的内存块,所述共享内存池用于提供至少两种不同长度的内存块的内存申请服务,所述至少两种不同长度中的每一种长度小于或等于所述预定长度,n≥2且n为正整数;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;
分配单元,用于从所述共享内存池中获取一个长度为所述需求长度的内存块进行分配使用。And an allocating unit, configured to obtain, from the shared memory pool, a memory block of a length of the required length for allocation.
在第一方面的第一种可能的实施方式中,所述分配单元,具体用于:In a first possible implementation manner of the first aspect, the allocating unit is specifically configured to:
检测所述共享内存池中是否存在空闲的且长度为所述需求长度的第一内存块;Detecting, in the shared memory pool, whether there is a first memory block that is idle and has a length of the required length;
若所述共享内存池中存在所述第一内存块,则将所述第一内存块进行分配使用。If the first memory block exists in the shared memory pool, the first memory block is allocated for use.
结合第一方面的第一种可能的实施方式,在第一方面的第二种可能的实施方式中,所述分配单元,具体还用于:In conjunction with the first possible implementation of the first aspect, in a second possible implementation of the first aspect, the allocating unit is further configured to:
若所述共享内存池中不存在所述第一内存块,则从所述共享内存池中选取空闲的且长度大于所述需求长度的第二内存块;If 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;
将所述第二内存块划分为m个内存块,所述m个内存块中包含长度为所述需求长度的内存块,m≥2且m为整数;Dividing the second memory block into m memory blocks, where the m memory blocks include a memory block having a length of the required length, m≥2 and m is an integer;
从所述m个内存块中选取所述长度为所述需求长度的内存块进行分配使用。And selecting, from the m memory blocks, the memory block whose length is the required length for allocation and use.
结合第一方面的第二种可能的实施方式,在第一方面的第三种可能的实施方式中,所述分配单元,具体还用于:In conjunction with the second possible implementation of the first aspect, in a third possible implementation of the first aspect, the allocating unit is further configured to:
当所述共享内存池中存在至少两种不同长度的所述第二内存块时,从所述共享内存池中选取空闲的、长度大于且最接近于所述需求长度的第二内存块。When there are at least two different lengths of the second memory block in the shared memory pool, an idle second memory block having a length greater than and closest to the required length is selected from the shared memory pool.
结合第一方面、第一方面的第一种可能的实施方式、第一方面的第二种可能的实施方式或者第一方面的第三种可能的实施方式,在第一方面的第四种可能的实施方式中,所述装置还包括: In conjunction with the first aspect, the first possible implementation of the first aspect, the second possible implementation of the first aspect, or the third possible implementation of the first aspect, the fourth possibility in the first aspect In an embodiment, 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.
结合第一方面、第一方面的第一种可能的实施方式、第一方面的第二种可能的实施方式、第一方面的第三种可能的实施方式或者第一方面的第四种可能的实施方式,在第一方面的第五种可能的实施方式中,所述至少两种不同长度的内存块包括w级不同长度的内存块,且第i+1级内存块的长度是第i级内存块的长度的q倍,第w级内存块的长度为所述预定长度,w≥2,1≤i≤w-1,q≥2且w、i、q均为整数。Combining the first aspect, the first possible implementation of the first aspect, the second possible implementation of the first aspect, the third possible implementation of the first aspect, or the fourth possible aspect of the first aspect In a fifth possible implementation manner of the first aspect, 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.
第二方面,提供了一种内存管理装置,所述装置包括:控制器和寄存器;In a second aspect, a memory management apparatus is provided, the 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:
获取预定大小的待分配内存;Obtaining a predetermined size of memory to be allocated;
根据所述待分配内存创建共享内存池,所述共享内存池中包括将所述待分配内存划分得到的n个长度为预定长度的内存块,所述共享内存池用于提供至少两种不同长度的内存块的内存申请服务,所述至少两种不同长度中的每一种长度小于或等于所述预定长度,n≥2且n为正整数;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;
获取内存申请所对应的需求长度,所述需求长度是所述至少两种不同长度中的一种;Obtaining a required length corresponding to the memory application, where the required length is one of the at least two different lengths;
从所述共享内存池中获取一个长度为所述需求长度的内存块进行分配使用;Obtaining, by using the shared memory pool, a memory block of a length of the required length for allocation and use;
所述控制器用于执行所述指令。The controller is operative to execute the instructions.
在第二方面的第一种可能的实施方式中,所述寄存器还存储有用于执行以下操作的指令: In a first possible implementation of the second aspect, the register further stores instructions for performing the following operations:
检测所述共享内存池中是否存在空闲的且长度为所述需求长度的第一内存块;Detecting, in the shared memory pool, whether there is a first memory block that is idle and has a length of the required length;
若所述共享内存池中存在所述第一内存块,则将所述第一内存块进行分配使用;If 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.
结合第二方面的第一种可能的实施方式,在第二方面的第二种可能的实施方式中,所述寄存器还存储有用于执行以下操作的指令:In conjunction with the first possible implementation of the second aspect, in a second possible implementation of the second aspect, the register further stores instructions for performing the following operations:
当所述共享内存池中不存在所述第一内存块时,从所述共享内存池中选取空闲的且长度大于所述需求长度的第二内存块;When 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;
将所述第二内存块划分为m个内存块,所述m个内存块中包含长度为所述需求长度的内存块,m≥2且m为整数;Dividing the second memory block into m memory blocks, where the m memory blocks include a memory block having a length of the required length, m≥2 and m is an integer;
从所述m个内存块中选取所述长度为所述需求长度的内存块进行分配使用;And selecting, from the m memory blocks, the memory block whose length is the required length for allocation and use;
所述控制器还用于执行所述指令。The controller is also operative to execute the instructions.
结合第二方面的第二种可能的实施方式,在第二方面的第三种可能的实施方式中,所述寄存器还存储有用于执行以下操作的指令:In conjunction with the second possible implementation of the second aspect, in a third possible implementation of the second aspect, the register further stores instructions for performing the following operations:
当所述共享内存池中存在至少两种不同长度的所述第二内存块时,从所述共享内存池中选取空闲的、长度大于且最接近于所述需求长度的第二内存块;When there are at least two different memory blocks of different lengths in the shared memory pool, select a second memory block that is free from the shared memory pool and has a length greater than and closest to the required length;
所述控制器还用于执行所述指令。The controller is also operative to execute the instructions.
结合第二方面、第二方面的第一种可能的实施方式、第二方面的第二种可能的实施方式或者第二方面的第三种可能的实施方式,在第二方面的第四种可能的实施方式中,所述寄存器还存储有用于执行以下操作的指令:With reference to the second aspect, the first possible implementation of the second aspect, the second possible implementation of the second aspect, or the third possible implementation of the second aspect, the fourth possibility in the second aspect In an embodiment, the register further stores instructions for performing the following operations:
获取需要释放的内存块对应的内存地址和长度;Get the memory address and length corresponding to the memory block that needs to be released;
当所述需要释放的内存块的长度小于所述预定长度时,根据所述内存地址检测所述需要释放的内存块所属的目标内存块中的其它内存块是否空闲,所述目标内存块的长度是所述至少两种不同长度中的一种且所述目标内存块的长度大于且最接近于所述需要释放的内存块的长度;When 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;
若所述其它内存块空闲,则将所述需要释放的内存块和所述其它内存块合并为所述目标内存块,所述目标内存块的长度是所述至少两种不同长度中的一种;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.
结合第二方面、第二方面的第一种可能的实施方式、第二方面的第二种可能的实施方式、第二方面的第三种可能的实施方式或者第二方面的第四种可能的实施方式,在第二方面的第五种可能的实施方式中,所述至少两种不同长度的内存块包括w级不同长度的内存块,且第i+1级内存块的长度是第i级内存块的长度的q倍,第w级内存块的长度为所述预定长度,w≥2,1≤i≤w-1,q≥2且w、i、q均为整数。Combining the second aspect, the first possible implementation of the second aspect, the second possible implementation of the second aspect, the third possible implementation of the second aspect, or the fourth possible aspect of the second aspect The fifth possible implementation manner of the second aspect, 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.
第三方面,提供了一种内存管理方法,所述方法包括:In a third aspect, a memory management method is provided, the method comprising:
获取预定大小的待分配内存;Obtaining a predetermined size of memory to be allocated;
根据所述待分配内存创建共享内存池,所述共享内存池中包括将所述待分配内存划分得到的n个长度为预定长度的内存块,所述共享内存池用于提供至少两种不同长度的内存块的内存申请服务,所述至少两种不同长度中的每一种长度小于或等于所述预定长度,n≥2且n为正整数;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;
获取内存申请所对应的需求长度,所述需求长度是所述至少两种不同长度中的一种;Obtaining a required length corresponding to the memory application, where the required length is one of the at least two different lengths;
从所述共享内存池中获取一个长度为所述需求长度的内存块进行分配使用。Obtaining a memory block of the required length from the shared memory pool for allocation.
在第三方面的第一种可能的实施方式中,所述从所述共享内存池中获取一个长度为所述需求长度的内存块进行分配使用,包括:In a first possible implementation manner of the third aspect, the obtaining, by using the shared memory pool, a memory block of the required length, for use, includes:
检测所述共享内存池中是否存在空闲的且长度为所述需求长度的第一内存块;Detecting, in the shared memory pool, whether there is a first memory block that is idle and has a length of the required length;
若所述共享内存池中存在所述第一内存块,则将所述第一内存块进行分配使用。If the first memory block exists in the shared memory pool, the first memory block is allocated for use.
结合第三方面的第一种可能的实施方式,在第三方面的第二种可能的实施方式中,所述检测所述共享内存池中是否存在空闲的且长度为所述需求长度的第一内存块之后,还包括:With reference to the first possible implementation manner of the third aspect, in a second possible implementation manner of the third aspect, 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:
若所述共享内存池中不存在所述第一内存块,则从所述共享内存池中选取空闲的且长度大于所述需求长度的第二内存块;If 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;
将所述第二内存块划分为m个内存块,所述m个内存块中包含长度为所述需求长度的内存块,m≥2且m为整数;Dividing the second memory block into m memory blocks, where the m memory blocks include a memory block having a length of the required length, m≥2 and m is an integer;
从所述m个内存块中选取所述长度为所述需求长度的内存块进行分配使 用。And selecting, from the m memory blocks, the memory block having the length of the required length to be allocated use.
结合第三方面的第二种可能的实施方式,在第三方面的第三种可能的实施方式中,所述从所述共享内存池中选取空闲的且长度大于所述需求长度的第二内存块,包括:With reference to the second possible implementation manner of the third aspect, in a third possible implementation manner of the third aspect, the selecting, from the shared memory pool, the second memory that is idle and has a length greater than the required length Blocks, including:
当所述共享内存池中存在至少两种不同长度的所述第二内存块时,从所述共享内存池中选取空闲的、长度大于且最接近于所述需求长度的第二内存块。When there are at least two different lengths of the second memory block in the shared memory pool, an idle second memory block having a length greater than and closest to the required length is selected from the shared memory pool.
结合第三方面、第三方面的第一种可能的实施方式、第三方面的第二种可能的实施方式或者第三方面的第三种可能的实施方式,在第三方面的第四种可能的实施方式中,所述方法还包括:In combination with the third aspect, the first possible implementation of the third aspect, the second possible implementation of the third aspect, or the third possible implementation of the third aspect, the fourth possibility in the third aspect In an embodiment, the method further includes:
获取需要释放的内存块对应的内存地址和长度;Get the memory address and length corresponding to the memory block that needs to be released;
当所述需要释放的内存块的长度小于所述预定长度时,根据所述内存地址检测所述需要释放的内存块所属的目标内存块中的其它内存块是否空闲,所述目标内存块的长度是所述至少两种不同长度中的一种且所述目标内存块的长度大于且最接近于所述需要释放的内存块的长度;When 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;
若所述其它内存块空闲,则将所述需要释放的内存块和所述其它内存块合并为所述目标内存块,所述目标内存块的长度是所述至少两种不同长度中的一种。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 .
结合第三方面、第三方面的第一种可能的实施方式、第三方面的第二种可能的实施方式、第三方面的第三种可能的实施方式或者第三方面的第四种可能的实施方式,在第三方面的第五种可能的实施方式中,所述至少两种不同长度的内存块包括w级不同长度的内存块,且第i+1级内存块的长度是第i级内存块的长度的q倍,第w级内存块的长度为所述预定长度,w≥2,1≤i≤w-1,q≥2且w、i、q均为整数。Combining the third aspect, the first possible implementation of the third aspect, the second possible implementation of the third aspect, the third possible implementation of the third aspect, or the fourth possible aspect of the third aspect The fifth possible implementation manner of the third aspect, 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 beneficial effects of the technical solutions provided by the embodiments of the present invention include:
通过创建共享内存池,由该共享内存池提供至少两种不同长度的内存块的申请服务,并在获取内存申请所对应的需求长度时,从共享内存池中获取一个长度为需求长度的内存块进行分配使用;解决了相关技术存在的内存浪费严重,内存的总利用率低的问题;通过不同长度的内存块共用一个共享内存池,既可以保证在内存分配时应对不同长度内存块的峰值需求,又可以达到节约内存、提高内存的总利用率的效果。 By creating a shared memory pool, 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.
附图说明DRAWINGS
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly described below. It is obvious that the drawings in the following description are only some embodiments of the present invention. Other drawings may also be obtained from those of ordinary skill in the art in light of the inventive work.
图1是本发明各个实施例所涉及的一种实施环境的示意图;1 is a schematic diagram of an implementation environment involved in various embodiments of the present invention;
图2是本发明一个实施例提供的内存管理装置的结构方框图;2 is a block diagram showing the structure of a memory management apparatus according to an embodiment of the present invention;
图3是本发明另一实施例提供的内存管理装置的结构方框图;3 is a block diagram showing the structure of a memory management apparatus according to another embodiment of the present invention;
图4是本发明再一实施例提供的内存管理装置的结构示意图;4 is a schematic structural diagram of a memory management apparatus according to still another embodiment of the present invention;
图5是本发明一个实施例提供的内存管理方法的方法流程图;FIG. 5 is a flowchart of a method for a memory management method according to an embodiment of the present invention; FIG.
图6A是本发明另一实施例提供的内存管理方法的方法流程图;6A is a flowchart of a method for a memory management method according to another embodiment of the present invention;
图6B是采用背景技术提供的内存管理方法所创建的内存池的示意图;6B is a schematic diagram of a memory pool created by the memory management method provided by the background technology;
图6C是采用本发明实施例提供的内存管理方法所创建的内存池的示意图;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是本发明另一实施例提供的内存管理方法中步骤604所涉及的流程图;FIG. 6D is a flowchart related to step 604 in the memory management method according to another embodiment of the present invention;
图6E是采用本发明实施例提供的内存管理方法所涉及的内存分配的示意图;6E is a schematic diagram of memory allocation involved in a memory management method provided by an embodiment of the present invention;
图7A/图7B是本发明再一实施例提供的内存管理方法的方法流程图;7A/7B are flowcharts of a method for a memory management method according to still another embodiment of the present invention;
图8是本发明还一实施例提供的内存管理方法的方法流程图。FIG. 8 is a flowchart of a method for a memory management method according to still another embodiment of the present invention.
具体实施方式detailed description
为使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明实施方式作进一步地详细描述。The embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.
请参考图1,其示出了本发明各个实施例所涉及的一种实施环境的示意图,该实施环境包括:处理器(英文:Central Processing Unit;简称:CPU)10和存储器20,处理器10与存储器20之间可通过总线相连。其中:Please refer to FIG. 1 , which 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:
处理器10可以是单核处理器,也可以是多核处理器。处理器10内部设置有内存管理装置11,该内存管理装置11是用于对内存进行管理的硬件装置,如BMU。如图1所示,内存管理装置11中包括控制器11a和寄存器11b。控 制器11a与寄存器11b之间电性相连。寄存器11b中存储有一个或者一个以上用于对内存进行管理的指令,该指令被配置成由控制器11a执行,以实现对内存进行管理。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. As shown in FIG. 1, 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.
可选的,如图1所示,处理器10内部还可设置有高速缓冲存储器Cache12。Cache12用于存储从存储器20调入的存储单元,以满足处理器10对数据进行高速存取的需求。Optionally, as shown in FIG. 1 , 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.
首先需要说明的一点是:本发明实施例提供的技术方案所采用的内存管理方式为块内存管理方式。块内存管理方式是指内存初始化时将内存划分为若干个内存块,后续内存申请和内存释放的粒度为一个内存块的内存管理方式。采用块内存管理方式,可防止因内存的反复申请和释放而产生大量内存碎片的问题,同时提高内存分配效率。It should be noted that 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.
还需要说明的一点是:正是由于块内存管理方式所具有的上述优势,本发明实施例提供的内存管理装置主要应用于对数据具有高速存取需求的设备中,如基站设备、路由器、交换机等。以基站设备为例,在不同的通信系统中,基站设备可以是基站收发信台(英文:Base Transmitter Station,简称:BTS)、基站(英文:Node Base station,简称:Node B)、演进型基站(英文:Evolved Node Base station,简称:eNB)等。当然,在其它可能的应用场景中,本发明实施例提供的内存管理装置也可应用于任何具有数据存取需求的电子设备中,该电子设备包括但不限于终端设备、服务器、传输设备等,对此本发明实施例不作限定。It should be noted that the memory management device provided by the embodiment of the present invention 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. Taking a base station device as an example, in different communication systems, 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). Of course, in other possible application scenarios, 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.
下面,对本发明实施例提供的技术方案进行介绍和说明。The technical solutions provided by the embodiments of the present invention are described and illustrated below.
请参考图2,其示出了本发明一个实施例提供的内存管理装置的结构方框图。该内存管理装置可通过软件、硬件或者两者的结合实现。该内存管理装置可设置于处理器内部,用于对内存进行管理。该内存管理装置可以包括:第一获取单元210、创建单元220、第二获取单元230和分配单元240。Please refer to FIG. 2, which 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.
第一获取单元210,用于获取预定大小的待分配内存。The first obtaining unit 210 is configured to acquire a memory to be allocated of a predetermined size.
创建单元220,用于根据第一获取单元210获取的待分配内存创建共享内存池。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.
其中,共享内存池中包括将待分配内存划分得到的n个长度为预定长度的内存块,共享内存池用于提供至少两种不同长度的内存块的内存申请服务,该 至少两种不同长度中的每一种长度小于或等于上述预定长度,n≥2且n为正整数。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.
第二获取单元230,用于获取内存申请所对应的需求长度,该需求长度是上述至少两种不同长度中的一种。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.
分配单元240,用于从创建单元220创建的共享内存池中获取一个长度为第二获取单元230获取的需求长度的内存块进行分配使用。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.
综上所述,本实施例提供的内存管理装置,通过创建共享内存池,由该共享内存池提供至少两种不同长度的内存块的申请服务,并在获取内存申请所对应的需求长度时,从共享内存池中获取一个长度为需求长度的内存块进行分配使用;解决了相关技术存在的内存浪费严重,内存的总利用率低的问题;通过不同长度的内存块共用一个共享内存池,既可以保证在内存分配时应对不同长度内存块的峰值需求,又可以达到节约内存、提高内存的总利用率的效果。In summary, the memory management apparatus 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.
请参考图3,其示出了本发明另一实施例提供的内存管理装置的结构方框图。该内存管理装置可通过软件、硬件或者两者的结合实现。该内存管理装置可设置于处理器内部,用于对内存进行管理。该内存管理装置可以包括:第一获取单元210、创建单元220、第二获取单元230和分配单元240。Please refer to FIG. 3, which 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.
第一获取单元210,用于向操作系统申请预定大小的待分配内存。The first obtaining unit 210 is configured to apply, to the operating system, a memory of a predetermined size to be allocated.
创建单元220,用于根据第一获取单元210获取的待分配内存创建共享内存池。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.
其中,共享内存池中包括将待分配内存划分得到的n个长度为预定长度的内存块,共享内存池用于提供至少两种不同长度的内存块的内存申请服务,该至少两种不同长度中的每一种长度小于或等于上述预定长度,n≥2且n为正整数。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.
可选的,该至少两种不同长度的内存块包括w级不同长度的内存块,且第i+1级内存块的长度是第i级内存块的长度的q倍,第w级内存块的长度为预定长度,w≥2,1≤i≤w-1,q≥2且w、i、q均为整数。Optionally, 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.
第二获取单元230,用于获取内存申请所对应的需求长度,该需求长度是上述至少两种不同长度中的一种。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.
分配单元240,用于从创建单元220创建的共享内存池中获取一个长度为第二获取单元230获取的需求长度的内存块进行分配使用。 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.
其中,分配单元240,具体用于:The allocating unit 240 is specifically configured to:
检测共享内存池中是否存在空闲的且长度为需求长度的第一内存块;Detecting whether there is a first memory block that is idle and has a length of required length in the shared memory pool;
若共享内存池中存在第一内存块,则将第一内存块进行分配使用。If the first memory block exists in the shared memory pool, the first memory block is allocated for use.
可选的,分配单元240,具体还用于:Optionally, the allocating unit 240 is specifically configured to:
若共享内存池中不存在第一内存块,则从共享内存池中选取空闲的且长度大于需求长度的第二内存块;If the first memory block does not exist in the shared memory pool, the second memory block that is free and longer than the required length is selected from the shared memory pool;
将第二内存块划分为m个内存块,该m个内存块中包含长度为需求长度的内存块,m≥2且m为整数;Dividing the second memory block into m memory blocks, where the m memory blocks include memory blocks of a required length, m≥2 and m is an integer;
从该m个内存块中选取长度为需求长度的内存块进行分配使用。A memory block of a required length is selected from the m memory blocks for allocation.
可选的,分配单元240,具体还用于:Optionally, the allocating unit 240 is specifically configured to:
当共享内存池中存在至少两种不同长度的第二内存块时,从共享内存池中选取空闲的、长度大于且最接近于需求长度的第二内存块。When there are at least two second memory blocks of different lengths in the shared memory pool, the second memory block having a length greater than and closest to the required length is selected from the shared memory pool.
可选的,该装置还包括:第三获取单元250、检测单元260和合并单元270。Optionally, the device further includes: a third obtaining unit 250, a detecting unit 260, and a merging unit 270.
第三获取单元250,用于获取需要释放的内存块对应的内存地址和长度。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.
检测单元260,用于当需要释放的内存块的长度小于预定长度时,根据第三获取单元250获取的内存地址检测该需要释放的内存块所属的目标内存块中的其它内存块是否空闲,该目标内存块的长度是上述至少两种不同长度中的一种且该目标内存块的长度大于且最接近于需要释放的内存块的长度。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.
合并单元270,用于当其它内存块空闲时,将需要释放的内存块和其它内存块合并为上述目标内存块,该目标内存块的长度是上述至少两种不同长度中的一种。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.
综上所述,本实施例提供的内存管理装置,通过创建共享内存池,由该共享内存池提供至少两种不同长度的内存块的申请服务,并在获取内存申请所对应的需求长度时,从共享内存池中获取一个长度为需求长度的内存块进行分配使用;解决了相关技术存在的内存浪费严重,内存的总利用率低的问题;通过不同长度的内存块共用一个共享内存池,既可以保证在内存分配时应对不同长度内存块的峰值需求,又可以达到节约内存、提高内存的总利用率的效果。In summary, the memory management apparatus 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.
另外,本实施例提供的内存管理装置,在内存分配时,当共享内存池中不存在长度为需求长度的内存块时,通过从长度大于需求长度的内存块中划分得到长度为需求长度的内存块进行分配,采用上述变长的块内存分配方式,使得共享内存池可提供多种不同长度的块内存的内存申请服务,且分配过程灵活高 效。In addition, in the memory management apparatus provided in this embodiment, 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.
另外,本实施例提供的内存管理装置,当共享内存池中存在至少两种不同长度的第二内存块时,还通过从共享内存池中选取空闲的、长度大于且最接近于需求长度的第二内存块,可以提高内存分配的可靠性和灵活性,以应对后续不同的内存申请需求。In addition, the memory management apparatus 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.
另外,本实施例提供的内存管理装置,还通过将长度小的内存块合并为长度大的内存块,尽量保证共享内存池中存在充足的且长度较大的空闲内存块,以便为后续不同的内存申请需求提供保障,确保内存分配的可靠性和效率。In addition, 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.
需要说明的是:上述实施例提供的内存管理装置在进行内存管理时,仅以上述各功能单元的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元完成,即将设备的内部结构划分成不同的功能单元,以完成以上描述的全部或者部分功能。另外,上述实施例提供的内存管理装置与下述实施例提供的内存管理方法的方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。It should be noted that, when 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. In addition, 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.
请参考图4,其示出了本发明再一实施例提供的内存管理装置的结构示意图。该内存管理装置400可以是设置于处理器内部、用于对内存进行管理的硬件装置,如BMU。该内存管理装置400可以包括:控制器410和寄存器420。其中:Please refer to FIG. 4, which 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:
寄存器420用于存储一个或者一个以上的指令,该指令用于实现一种内存管理方法,该指令包括:The register 420 is configured to store one or more instructions for implementing a memory management method, the instruction comprising:
获取预定大小的待分配内存;Obtaining a predetermined size of memory to be allocated;
根据待分配内存创建共享内存池,该共享内存池中包括将待分配内存划分得到的n个长度为预定长度的内存块,该共享内存池用于提供至少两种不同长度的内存块的内存申请服务,该至少两种不同长度中的每一种长度小于或等于上述预定长度,n≥2且n为正整数;Creating a shared memory pool according to the memory to be allocated, 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 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;
获取内存申请所对应的需求长度,该需求长度是上述至少两种不同长度中的一种;Obtaining a length of the requirement corresponding to the memory application, where the required length is one of the at least two different lengths;
从共享内存池中获取一个长度为上述需求长度的内存块进行分配使用;Obtaining a memory block of the length of the above requirement from the shared memory pool for allocation;
控制器410用于执行上述指令。 The controller 410 is configured to execute the above instructions.
综上所述,本实施例提供的内存管理装置,通过创建共享内存池,由该共享内存池提供至少两种不同长度的内存块的申请服务,并在获取内存申请所对应的需求长度时,从共享内存池中获取一个长度为需求长度的内存块进行分配使用;解决了相关技术存在的内存浪费严重,内存的总利用率低的问题;通过不同长度的内存块共用一个共享内存池,既可以保证在内存分配时应对不同长度内存块的峰值需求,又可以达到节约内存、提高内存的总利用率的效果。In summary, the memory management apparatus 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.
在基于图4所示实施例提供的可选实施例中,寄存器420还存储有用于执行以下操作的指令:In an alternative embodiment provided based on the embodiment illustrated in Figure 4, the register 420 also stores instructions for performing the following operations:
检测共享内存池中是否存在空闲的且长度为需求长度的第一内存块;Detecting whether there is a first memory block that is idle and has a length of required length in the shared memory pool;
若共享内存池中存在第一内存块,则将第一内存块进行分配使用;If the first memory block exists in the shared memory pool, the first memory block is allocated for use;
控制器410还用于执行上述指令。The controller 410 is also operative to execute the above instructions.
在基于图4所示实施例提供的可选实施例中,寄存器420还存储有用于执行以下操作的指令:In an alternative embodiment provided based on the embodiment illustrated in Figure 4, the register 420 also stores instructions for performing the following operations:
当共享内存池中不存在第一内存块时,从共享内存池中选取空闲的且长度大于需求长度的第二内存块;When the first memory block does not exist in the shared memory pool, select a second memory block that is free and longer than the required length from the shared memory pool;
将第二内存块划分为m个内存块,该m个内存块中包含长度为需求长度的内存块,m≥2且m为整数;Dividing the second memory block into m memory blocks, where the m memory blocks include memory blocks of a required length, m≥2 and m is an integer;
从该m个内存块中选取长度为需求长度的内存块进行分配使用;Allocating a memory block of a required length from the m memory blocks for allocation and use;
控制器410还用于执行上述指令。The controller 410 is also operative to execute the above instructions.
在基于图4所示实施例提供的可选实施例中,寄存器420还存储有用于执行以下操作的指令:In an alternative embodiment provided based on the embodiment illustrated in Figure 4, the register 420 also stores instructions for performing the following operations:
当共享内存池中存在至少两种不同长度的第二内存块时,从共享内存池中选取空闲的、长度大于且最接近于需求长度的第二内存块;When there are at least two second memory blocks of different lengths in the shared memory pool, select a second memory block that is free from the shared memory pool and has a length greater than and closest to the required length;
控制器410还用于执行上述指令。The controller 410 is also operative to execute the above instructions.
在基于图4所示实施例提供的可选实施例中,寄存器420还存储有用于执行以下操作的指令:In an alternative embodiment provided based on the embodiment illustrated in Figure 4, the register 420 also stores instructions for performing the following operations:
获取需要释放的内存块对应的内存地址和长度;Get the memory address and length corresponding to the memory block that needs to be released;
当需要释放的内存块的长度小于预定长度时,根据内存地址检测该需要释放的内存块所属的目标内存块中的其它内存块是否空闲,该目标内存块的长度是上述至少两种不同长度中的一种且该目标内存块的长度大于且最接近于需要释放的内存块的长度; When 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;
若其它内存块空闲,则将需要释放的内存块和其它内存块合并为上述目标内存块,该目标内存块的长度是上述至少两种不同长度中的一种;If other memory blocks are idle, 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;
控制器410还用于执行上述指令。The controller 410 is also operative to execute the above instructions.
在基于图4所示实施例提供的可选实施例中,上述至少两种不同长度的内存块包括w级不同长度的内存块,且第i+1级内存块的长度是第i级内存块的长度的q倍,第w级内存块的长度为预定长度,w≥2,1≤i≤w-1,q≥2且w、i、q均为整数。In an optional embodiment provided by the embodiment shown in FIG. 4, 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.
综上所述,本实施例提供的内存管理装置,在内存分配时,当共享内存池中不存在长度为需求长度的内存块时,通过从长度大于需求长度的内存块中划分得到长度为需求长度的内存块进行分配,采用上述变长的块内存分配方式,使得共享内存池可提供多种不同长度的块内存的内存申请服务,且分配过程灵活高效。In summary, the memory management apparatus provided in this embodiment 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.
另外,本实施例提供的内存管理装置,当共享内存池中存在至少两种不同长度的第二内存块时,还通过从共享内存池中选取空闲的、长度大于且最接近于需求长度的第二内存块,可以提高内存分配的可靠性和灵活性,以应对后续不同的内存申请需求。In addition, the memory management apparatus 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.
另外,本实施例提供的内存管理装置,还通过将长度小的内存块合并为长度大的内存块,尽量保证共享内存池中存在充足的且长度较大的空闲内存块,以便为后续不同的内存申请需求提供保障,确保内存分配的可靠性和效率。In addition, 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 following are embodiments of the method of the present invention, each of which corresponds to the above apparatus embodiment. For details not disclosed in the embodiment of the device of the present invention, please refer to the method embodiment of the present invention.
请参考图5,其示出了本发明一个实施例提供的内存管理方法的方法流程图。本实施例以该内存管理方法应用于图1所示实施环境中的内存管理装置中进行举例说明,该内存管理装置可以是设置有处理器内部的BMU。该内存管理方法可以包括如下几个步骤:Please refer to FIG. 5, which is a flowchart of a method for a memory management method according to an embodiment of the present invention. In this embodiment, 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:
步骤502,获取预定大小的待分配内存。Step 502: Acquire a memory of a predetermined size to be allocated.
步骤504,根据待分配内存创建共享内存池,该共享内存池中包括将待分配内存划分得到的n个长度为预定长度的内存块,该共享内存池用于提供至少两种不同长度的内存块的内存申请服务,该至少两种不同长度中的每一种长度小于或等于上述预定长度,n≥2且n为正整数。 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.
步骤506,获取内存申请所对应的需求长度,该需求长度是上述至少两种不同长度中的一种。Step 506: Acquire a required length corresponding to the memory application, where the required length is one of the at least two different lengths.
步骤508,从共享内存池中获取一个长度为上述需求长度的内存块进行分配使用。Step 508: Obtain a memory block with a length of the required length from the shared memory pool for allocation.
综上所述,本实施例提供的内存管理方法,通过创建共享内存池,由该共享内存池提供至少两种不同长度的内存块的申请服务,并在获取内存申请所对应的需求长度时,从共享内存池中获取一个长度为需求长度的内存块进行分配使用;解决了相关技术存在的内存浪费严重,内存的总利用率低的问题;通过不同长度的内存块共用一个共享内存池,既可以保证在内存分配时应对不同长度内存块的峰值需求,又可以达到节约内存、提高内存的总利用率的效果。In summary, 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.
请参考图6A,其示出了本发明另一实施例提供的内存管理方法的方法流程图。本实施例以该内存管理方法应用于图1所示实施环境中的内存管理装置中进行举例说明,该内存管理装置可以是设置有处理器内部的BMU。该内存管理方法可以包括如下几个步骤:Please refer to FIG. 6A, which is a flowchart of a method for a memory management method according to another embodiment of the present invention. In this embodiment, 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:
步骤601,获取预定大小的待分配内存。Step 601: Acquire a memory of a predetermined size to be allocated.
内存管理装置通过步骤601和步骤602对内存进行初始化配置。The memory management device initializes the memory through steps 601 and 602.
首先,内存管理装置自身向操作系统申请预定大小的待分配内存,或者通过软件向操作系统申请预定大小的待分配内存。其中,预定大小可以是根据实际需求预先设定的经验值。比如,预定大小可根据内存申请所需的各种不同长度的内存块的使用峰值预先进行设定;和/或,预定大小也可根据操作系统所管理的物理内存的大小预先进行设定。First, 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.
另外,在通常情况下,操作系统提供给内存管理装置的待分配内存所对应的预定大小小于操作系统所管理的物理内存的大小。比如,假设操作系统所管理的物理内存的大小为M,则操作系统可将大小为N的内存提供给内存管理装置作为可分配内存,其中M>N。操作系统预留的大小为M-N的内存是操作系统正常运行所需的内存。In addition, under normal circumstances, 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. For example, if 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.
步骤602,根据待分配内存创建共享内存池。Step 602: Create a shared memory pool according to the memory to be allocated.
之后,内存管理装置根据申请得到的待分配内存创建共享内存池。其中,共享内存池中包括将待分配内存划分得到的n个长度为预定长度的内存块,n≥2且n为正整数。该共享内存池用于提供至少两种不同长度的内存块的内存 申请服务,该至少两种不同长度中的每一种长度小于或等于上述预定长度。比如,当预定长度为4X时,共享内存池可提供长度为X、2X和4X等不同长度的内存块的内存申请服务。再比如,当预定长度为5X时,共享内存池可提供长度为X、2X、3X、4X和5X等不同长度的内存块的内存申请服务。After that, 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.
与背景技术所提供的内存管理方法所不同的是:在背景技术提供的内存管理方法中,当内存管理装置需要向外提供w种不同长度的内存块的内存申请服务时,其需要创建w个内存池,w≥2且w为整数。比如,如图6B所示,若采用背景技术提供的内存管理方法,当内存管理装置需要向外提供长度分别为X、2X和4X三种不同长度的内存块的内存申请服务时,其需要创建3个内存池,如图6B中内存池1、内存池2和内存池3。其中,内存池1中包括n1个长度为X的内存块,内存池2中包括n2个长度为2X的内存块,内存池3中包括n3个长度为4X的内存块。Different from the memory management method provided by the background art, in the memory management method provided by the background art, 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. For example, as shown in 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, and the memory pool 2 includes n 2 memory blocks of length 2X, and the memory pool 3 includes n 3 memory blocks of length 4X.
而在本实施例中,当内存管理装置需要向外提供w种不同长度的内存块的内存申请服务时,其仅需创建一个共享内存池,w≥2且w为整数。仍然以内存管理装置向外提供长度分别为X、2X和4X三种不同长度的内存块的内存申请服务为例,如图6C所示,内存管理装置创建一个共享内存池,该共享内存池中包括n个长度为4X的内存块。换句话说,在本实施例中,当内存管理装置需要向外提供多种不同长度的内存块的内存申请服务时,其对外可呈现多个内存池,而对内仅需维护一个内存池。In this embodiment, 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. For example, as shown in FIG. 6C, 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. In other words, in the embodiment, 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.
下面,通过步骤603和步骤604介绍内存分配过程:Next, the memory allocation process is introduced through steps 603 and 604:
步骤603,获取内存申请所对应的需求长度。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. Wherein, the required length is one of the above two different lengths.
比如,结合参考图6C,内存管理装置对外可呈现三个内存池,假设分别为Pool A、Pool B和Pool C。其中,Pool A对应于长度为X的内存块,Pool B对应于长度为2X的内存块,Pool C对应于长度为4X的内存块。当外部的软件和/或硬件需要申请长度为X的内存块时,访问Pool A;当外部的软件和/或硬件需要申请长度为2X的内存块时,访问Pool B;当外部的软件和/或硬件需要申请长度为4X的内存块时,访问Pool C。相应的,内存管理装置可根据外 部的软件和/或硬件所访问的内存池确定内存申请所对应的需求长度。For example, referring to FIG. 6C, the memory management device can externally present three memory pools, which are assumed to be Pool A, Pool B, and Pool C, respectively. Among them, Pool A corresponds to a memory block of length X, Pool B corresponds to a memory block of length 2X, and Pool C corresponds to a memory block of length 4X. When external software and/or hardware needs to apply for a memory block of length X, access Pool A; when external software and/or hardware needs to apply for a memory block of length 2X, access Pool B; when external software and / Or when the hardware needs to apply for a memory block of length 4X, access Pool C. Correspondingly, 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.
步骤604,从共享内存池中获取一个长度为上述需求长度的内存块进行分配使用。Step 604: Obtain a memory block of the length of the required length from the shared memory pool for allocation.
由于内存管理装置对内仅维护一个共享内存池,因此当内存管理装置获取到需求长度时,不论该需求长度是多少,内存管理装置均从共享内存池中获取一个长度为需求长度的内存块进行分配使用。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.
具体来讲,如图6D所示,本步骤可以包括如下几个子步骤:Specifically, as shown in FIG. 6D, this step may include the following sub-steps:
步骤604a,检测共享内存池中是否存在空闲的且长度为需求长度的第一内存块。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.
内存管理装置可使用不同的标识区分内存块是否空闲。当内存管理装置获取内存申请所对应的需求长度时,检测共享内存池中是否存在空闲的且长度为需求长度的第一内存块。结合参考图6C,比如,当需求长度为X时,内存管理装置检测共享内存池中是否存在空闲的且长度为X的内存块;再比如,当需求长度为2X时,内存管理装置检测共享内存池中是否存在空闲的且长度为2X的内存块,以此类推。The memory management device can use different identifiers to distinguish whether the memory block is free. When 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.
若共享内存池中存在上述第一内存块,则执行下述步骤604b;否则,执行下述步骤604c至步骤604e。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.
步骤604b,将第一内存块进行分配使用。In step 604b, the first memory block is allocated for use.
当共享内存池中存在空闲的且长度为需求长度的第一内存块时,内存管理装置将第一内存块进行分配使用。可选的,当满足上述要求的第一内存块的数量为多个时,内存管理装置从中选取一个第一内存块进行分配使用。When there is a first memory block that is free and has a length of required length in the shared memory pool, the memory management device allocates the first memory block. Optionally, when the number of the first memory blocks that meet the foregoing requirements is multiple, the memory management device selects one of the first memory blocks for allocation and use.
步骤604c,从共享内存池中选取空闲的且长度大于需求长度的第二内存块。Step 604c: Select, from the shared memory pool, a second memory block that is idle and has a length greater than a required length.
当共享内存池中不存在空闲的且长度为需求长度的第一内存块时,内存管理装置从共享内存池中选取空闲的且长度大于需求长度的第二内存块。结合参考图6C,比如,当需求长度为X,而共享内存池中不存在空闲的且长度为X的内存块时,内存管理装置检测共享内存池中是否存在空闲的且长度为2X或4X的内存块;再比如,当需求长度为2X,而共享内存池中不存在空闲的且长度为2X的内存块时,内存管理装置检测共享内存池中是否存在空闲的且长度为4X的内存块,以此类推。When there is no idle first memory block of the required length in the shared memory pool, the memory management device selects a second memory block that is free and longer than the required length from the shared memory pool. Referring to FIG. 6C, for example, when the required length is X, and there is no free memory block of length X in 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.
可选的,内存管理装置在执行上述步骤604c之前还可执行如下步骤:当 共享内存池中不存在空闲的且长度为需求长度的第一内存块时,检测共享内存池中是否存在空闲的且长度大于需求长度的第二内存块;若共享内存池中存在满足上述要求的第二内存块,则执行上述步骤604c;否则,反馈内存分配失败的响应。其中,导致共享内存池中不存在满足上述要求的第二内存块的情况的原因可以包括:需求长度即为共享内存池所能提供的内存块的最大长度,且共享内存池中不存在空闲的且长度为需求长度的第一内存块;或者,共享内存池中存在长度大于需求长度的内存块,但这些内存块均处于使用状态。Optionally, 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.
步骤604d,将第二内存块划分为m个内存块,该m个内存块中包含长度为需求长度的内存块,m≥2且m为整数。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.
内存管理装置将选取的第二内存块划分为m个内存块,该m个内存块中包含至少一个长度为需求长度的内存块。比如,结合参考图6C和6E,假设初始化配置后共享内存池中存在n个长度为4X的内存块。当第一次内存申请所对应的需求长度为X时,内存管理装置可选取1个长度为4X的内存块,并将其划分为3个内存块(包括2个长度为X的内存块61、62和1个长度为2X的内存块63)。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.
步骤604e,从该m个内存块中选取长度为需求长度的内存块进行分配使用。Step 604e: Select a memory block of a required length from the m memory blocks for allocation and use.
内存管理装置从划分得到的m个内存块中选取长度为需求长度的内存块进行分配使用。可选的,当划分得到的m个内存块中存在多个长度为需求长度的内存块时,内存管理装置从中选取一个长度为需求长度的内存块分配使用。比如,对于上述举例的第一次内存申请,内存管理装置从划分得到的3个内存块中选取1个长度为X的内存块分配使用(如图6E中斜线所示的长度为X的内存块61)。再比如,假设第二次内存申请所对应的需求长度为2X时,内存管理装置可检测出共享内存池中存在空闲的且长度为2X的内存块,则将该长度为2X的内存块分配使用(如图6E中斜线所示的长度为2X的内存块63)。The memory management device selects a memory block of a required length from the divided m memory blocks for allocation. Optionally, when there are multiple memory blocks of a required length in the obtained m memory blocks, 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). For example, if the required length of the second memory application is 2X, 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).
可选的,对于上述步骤604c,当共享内存池中存在至少两种不同长度的第二内存块时,内存管理装置从共享内存池中选取空闲的、长度大于且最接近于需求长度的第二内存块。比如,当需求长度为X,而共享内存池中存在长度分别为2X和4X的第二内存块时,内存管理装置选取长度为2X的第二内存块。通过选取空闲的、长度大于且最接近于需求长度的第二内存块,可以提高内存分配的可靠性和灵活性,以应对后续不同的内存申请需求。 Optionally, for the foregoing step 604c, when there are at least two second memory blocks of different lengths in the shared memory pool, 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. By selecting an idle second memory block that is larger than the length and closest to the required length, the reliability and flexibility of the memory allocation can be improved to cope with subsequent different memory application requirements.
举例来讲,当某次内存申请所对应的需求长度为X,而共享内存池中还存在一个空闲的且长度为2X的内存块和一个空闲的且长度为4X的内存块。若内存管理装置选取长度为4X的内存块进行划分(假设划分为2个长度为X的内存块和1个长度为2X的内存块),则此次分配后共享内存池中还剩余的空闲的内存块包括1个长度为X的内存块和2个长度为2X的内存块,那么在无其它内存块释放的情况下,共享内存池无法继续提供长度为4X的内存块。若内存管理装置选取长度为2X的内存块进行划分(假设划分为2个长度为X的内存块),则此次分配后共享内存池中还剩余的空闲的内存块包括1个长度为X的内存块和1个长度为4X的内存块,那么在无其它内存块释放的情况下,共享内存池可以继续提供长度为X、2X或者4X的内存块。For example, when the memory request corresponds to a demand length of X, and the shared memory pool still has an idle 2X memory block and a free 4X memory block. If 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. Then, without other memory blocks being released, the shared memory pool cannot continue to provide a memory block of length 4X. If 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.
可选的,内存管理装置向外提供的至少两种不同长度的内存块可包括w级不同长度的内存块。其中,第i+1级内存块的长度是第i级内存块的长度的q倍,第w级内存块的长度为上述预定长度,w≥2,1≤i≤w-1,q≥2且w、i、q均为整数。比如,上述至少两种不同长度包括:X、2X、4X、8X等。再比如,上述至少两种不同长度包括X、3X、9X等。Optionally, 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. For example, the at least two different lengths mentioned above include: X, 2X, 4X, 8X, and the like. As another example, the at least two different lengths described above include X, 3X, 9X, and the like.
当然,本实施例并不限定其它可能的实施方式。比如,在其它可能的实施方式中,相邻级内存块之间的长度可不具有相同的倍数关系。比如,上述至少两种不同长度包括:X、4X、7X等。这样,当需要对长度为4X的内存块进行分割时,只能将其分割为4个长度为X的内存块,当需要对长度为7X的内存块进行分割时,只能将其分割为1个长度为4X的内存块和3个长度为X的内存块,长此以往将会导致共享内存池中剩余大量的长度较小的内存块(如长度为X的内存块),最终导致共享内存池无法应对长度较大的内存块的申请需求。因此,上述相邻级内存块之间的长度具有相同的倍数关系仅是一种较佳的实施方式,可以使得共享内存池在分割内存块时更为合理、灵活,防止内存碎片化,以应对后续不同的内存申请需求。Of course, this embodiment does not limit other possible implementations. For example, in other possible implementations, the lengths between adjacent levels of memory blocks may not have the same multiple relationship. For example, the at least two different lengths mentioned above include: X, 4X, 7X, and the like. In this way, when a memory block of length 4X needs to be divided, it can only be divided into four memory blocks of length X. When it is necessary to divide the memory block of length 7X, it can only be divided into 1 A memory block of length 4X and three memory blocks of length X will in the long run lead to a large number of memory blocks with a small length (such as a memory block of length X) remaining in the shared memory pool, eventually resulting in a shared memory pool. Respond to the application requirements of larger memory blocks. Therefore, it is only a preferred implementation that 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.
在本实施例中,通过不同长度的内存块共用一个共享内存池,既可以保证在内存分配时应对不同长度内存块的峰值需求,又可以达到节约内存、提高内存的总利用率的效果。具体来讲,假设内存管理装置需要向外提供w种不同长度的内存块的内存申请服务,若采用背景技术提供的内存管理方法,其至少需要向操作系统申请的待分配内存大小
Figure PCTCN2015072535-appb-000001
其中,Lk表示第k种长度的内存块的长度,nk表示第k种长度的内存块的峰值需求数量,w≥2且w为整 数。若采用本实施例提供的内存管理方法,内存管理装置向操作系统申请的待分配内存的大小N的范围为:
Figure PCTCN2015072535-appb-000002
In this embodiment, 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. Specifically, it is assumed that 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.
Figure PCTCN2015072535-appb-000001
Where L k represents the length of the kth length of the memory block, and n k represents the peak demand quantity of the kth length of the memory block, w ≥ 2 and w is an integer. According to the memory management method provided in this embodiment, the size N of the memory to be allocated that the memory management device applies to the operating system is:
Figure PCTCN2015072535-appb-000002
在一个具体的例子中,结合参考图6B,若采用背景技术提供的内存管理方法,假设X、2X和4X三种不同长度的内存块对应的使用峰值均为Y个,则内存管理装置至少需要向操作系统申请的待分配内存大小N=XY+2XY+4XY=7XY,这样才能保证内存分配能够应对不同长度内存块的峰值需求。结合参考图6C,若采用本实施例提供的内存管理方法,内存管理装置仅需向操作系统申请大小为4XY~5XY左右的待分配内存,即可保证内存分配能够应对不同长度内存块的峰值需求。可见,相比于背景技术提供的内存管理方法,在保证同样的内存分配需求的前提下,本实施例提供的内存管理方法可节约30%~40%左右的内存。尤其是对于嵌入式系统来讲,可充分满足嵌入式系统对内存容量和成本的要求。In a specific example, referring to FIG. 6B, if the memory management method provided by the background art is adopted, it is assumed that the memory blocks corresponding to the three different lengths of X, 2X, and 4X have Y peaks, and the memory management device needs at least The size of the memory to be allocated to the operating system is N=XY+2XY+4XY=7XY, so as to ensure that the memory allocation can cope with the peak demand of memory blocks of different lengths. Referring to FIG. 6C, if the memory management method provided in this embodiment is used, 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.
综上所述,本实施例提供的内存管理方法,通过创建共享内存池,由该共享内存池提供至少两种不同长度的内存块的申请服务,并在获取内存申请所对应的需求长度时,从共享内存池中获取一个长度为需求长度的内存块进行分配使用;解决了相关技术存在的内存浪费严重,内存的总利用率低的问题;通过不同长度的内存块共用一个共享内存池,既可以保证在内存分配时应对不同长度内存块的峰值需求,又可以达到节约内存、提高内存的总利用率的效果。In summary, 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.
另外,本实施例提供的内存管理方法,在内存分配时,当共享内存池中不存在长度为需求长度的内存块时,从长度大于需求长度的内存块中划分得到长度为需求长度的内存块进行分配,采用上述变长的块内存分配方式,使得共享内存池可提供多种不同长度的块内存的内存申请服务,且分配过程灵活高效。In addition, in the memory management method provided in this embodiment, when there is no memory block of a required length in the shared memory pool in the memory allocation, 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.
另外,本实施例提供的内存管理方法,当共享内存池中存在至少两种不同长度的第二内存块时,还通过从共享内存池中选取空闲的、长度大于且最接近于需求长度的第二内存块,可以提高内存分配的可靠性和灵活性,以应对后续不同的内存申请需求。In addition, 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.
请参考图7A/7B,其示出了本发明再一实施例提供的内存管理方法的方法流程图。如图7A所示,上述图6A所示实施例的步骤604a可以包括如下几个子步骤: Please refer to FIG. 7A/7B, which is a flowchart of a method for a memory management method according to still another embodiment of the present invention. As shown in FIG. 7A, the above step 604a of the embodiment shown in FIG. 6A may include the following sub-steps:
步骤604a1,检测共享内存池的指定内存块集合中是否存在第一内存块。Step 604a1: Detect whether a first memory block exists in a specified memory block set of the shared memory pool.
步骤604a2,若存在,则从指定内存块集合中选取第一内存块进行分配使用。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. Alternatively, 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.
在本实施例中,当获取到内存申请所对应的需求长度时,内存管理装置检测指定内存块集合中是否存在空闲的且长度为需求长度的第一内存块。当指定内存块集合中存在满足上述要求的第一内存块时,内存管理装置优先从指定内存块集合中选取一个第一内存块进行分配使用。内存管理装置通过精确控制内存块的分配使用,使得某一部分内存块被高频率地使用,这样有利于提高读取命中率和系统性能。In this embodiment, when the required length corresponding to the memory application is obtained, 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. When there is a first memory block in the specified memory block set that satisfies the above requirement, 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.
类似的,如图7B所示,上述图6A所示实施例的步骤604c可以包括如下几个子步骤:Similarly, as shown in FIG. 7B, the above step 604c of the embodiment shown in FIG. 6A may include the following sub-steps:
步骤604c1,检测共享内存池的指定内存块集合中是否存在第二内存块。Step 604c1: Detect whether a second memory block exists in the specified memory block set of the shared memory pool.
步骤604c2,若存在,则从指定内存块集合中选取第二内存块进行分配使用。Step 604c2, if present, selects a second memory block from the specified set of memory blocks for allocation.
在本实施例中,当共享内存池中不存在空闲的且长度为需求长度的第一内存块时,内存管理装置检测指定内存块集合中是否存在空闲的且长度大于需求长度的第二内存块。当指定内存块集合中存在满足上述要求的第二内存块时,内存管理装置优先从指定内存块集合中选取一个第二内存块进行分配使用。内存管理装置通过精确控制内存块的分配使用,使得某一部分内存块被高频率地使用,这样有利于提高读取命中率和系统性能。另外,当指定内存块集合中不存在满足上述要求的第二内存块时,内存管理装置从共享内存池中的其它内存块中获取一个满足上述要求的第二内存块进行分配使用。In this embodiment, when there is no idle first memory block of the required length in the shared memory pool, 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. . When there is a second memory block in the specified memory block set that satisfies the above requirements, 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. In addition, when there is no second memory block in the specified memory block set that satisfies the above requirement, 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.
需要说明的一点是:当指定内存块集合中不存在空闲的且长度为需求长度的第一内存块时,内存管理装置可以从共享内存池中的其它内存块中获取一个满足上述要求的第一内存块进行分配使用;或者,内存管理装置也可执行上述 步骤604c1,对此本实施例不作具体限定。It should be noted that when there is no idle first memory block of the required length in the specified memory block set, 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.
综上所述,本实施例提供的内存管理方法,在进行内存分配时,通过精确控制内存块的分配使用,使得某一部分内存块被高频率地使用,这样有利于提高读取命中率和系统性能。In summary, 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.
下面,通过图8所示实施例介绍内存释放过程:Next, the memory release process will be described by the embodiment shown in FIG. 8:
请参考图8,其示出了本发明还一实施例提供的内存管理方法的方法流程图。在该内存管理方法中,在图6A所示实施例的步骤602之后,还包括:Please refer to FIG. 8 , which is a flowchart of a method for a memory management method according to still another embodiment of the present invention. In the memory management method, after step 602 of the embodiment shown in FIG. 6A, the method further includes:
步骤605,获取需要释放的内存块对应的内存地址和长度。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.
步骤606,当需要释放的内存块的长度小于预定长度时,根据内存地址检测该需要释放的内存块所属的目标内存块中的其它内存块是否空闲。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.
步骤607,若其它内存块空闲,则将需要释放的内存块和其它内存块合并为目标内存块。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.
比如,结合参考图6E,当需要释放的内存块为长度为X的内存块61时,内存管理装置根据该内存块61的内存地址检测其所属的目标内存块中的其它内存块是否空闲。在图6E中,目标内存块即为由内存块61和内存块62所构成的长度为2X的内存块。若内存管理装置检测出内存块62空闲,则内存管理装置将内存块61和内存块62合并为一个长度为2X的内存块。另外,若内存管理装置检测出内存块62处于使用状态,则结束流程。For example, referring to FIG. 6E, when the memory block to be released is the memory block 61 of length X, 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. In FIG. 6E, 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.
进一步地,内存管理装置在合并得到目标内存块之后,还可继续检测是否可以将目标内存块和其它内存块合并为更高一级(也即长度更大)的内存块;若可以,则继续执行内存块合并步骤,直至得到一个长度为上述预定长度的内存块。比如,在图6E中,若内存块63也空闲,则内存管理装置可进一步将上述合并得到的一个长度为2X的内存块与内存块63合并为一个长度为4X的内存块。Further, after the memory management device merges the target memory block, it 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.
另外,当需要释放的内存块的长度等于预定长度时,结束流程。由于预定长度是共享内存池所能提供的内存块的最大长度,当需要释放的内存块的长度 等于预定长度时,内存管理装置无需执行内存块合并步骤。In addition, when the length of the memory block to be released is equal to the predetermined length, 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.
综上所述,本实施例提供的内存管理方法,还通过将长度小的内存块合并为长度大的内存块,尽量保证共享内存池中存在充足的且长度较大的空闲内存块,以便为后续不同的内存申请需求提供保障,确保内存分配的可靠性和效率。In summary, 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.
可以理解,图2至图4任一实施例提供的内存管理装置可以执行图5、图6A、图7A、图7B和图8任一实施例提供的内存管理方法,为描述之简洁,装置实施例各单元或组成部件的具体功能及工作流程可以参照方法实施例部分的相关,不做过多赘述,同时,本发明提供的各个实施例的内容描述也可以相互参照。It can be understood that 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. For example, 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.
以上所述仅为本发明的较佳实施例,并不用以限制本发明,凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。 The above are only the preferred embodiments of the present invention, and are not intended to limit the present invention. Any modifications, equivalents, improvements, etc., which are within the spirit and scope of the present invention, should be included in the protection of the present invention. Within the scope.

Claims (18)

  1. 一种内存管理装置,其特征在于,所述装置包括:A memory management device, characterized in that the device comprises:
    第一获取单元,用于获取预定大小的待分配内存;a first acquiring unit, configured to acquire a memory of a predetermined size to be allocated;
    创建单元,用于根据所述待分配内存创建共享内存池,所述共享内存池中包括将所述待分配内存划分得到的n个长度为预定长度的内存块,所述共享内存池用于提供至少两种不同长度的内存块的内存申请服务,所述至少两种不同长度中的每一种长度小于或等于所述预定长度,n≥2且n为正整数;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;
    分配单元,用于从所述共享内存池中获取一个长度为所述需求长度的内存块进行分配使用。And an allocating unit, configured to obtain, from the shared memory pool, a memory block of a length of the required length for allocation.
  2. 根据权利要求1所述的装置,其特征在于,所述分配单元,具体用于:The device according to claim 1, wherein the allocating unit is specifically configured to:
    检测所述共享内存池中是否存在空闲的且长度为所述需求长度的第一内存块;Detecting, in the shared memory pool, whether there is a first memory block that is idle and has a length of the required length;
    若所述共享内存池中存在所述第一内存块,则将所述第一内存块进行分配使用。If the first memory block exists in the shared memory pool, the first memory block is allocated for use.
  3. 根据权利要求2所述的装置,其特征在于,所述分配单元,具体还用于:The device according to claim 2, wherein the allocating unit is further configured to:
    若所述共享内存池中不存在所述第一内存块,则从所述共享内存池中选取空闲的且长度大于所述需求长度的第二内存块;If 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;
    将所述第二内存块划分为m个内存块,所述m个内存块中包含长度为所述需求长度的内存块,m≥2且m为整数;Dividing the second memory block into m memory blocks, where the m memory blocks include a memory block having a length of the required length, m≥2 and m is an integer;
    从所述m个内存块中选取所述长度为所述需求长度的内存块进行分配使用。And selecting, from the m memory blocks, the memory block whose length is the required length for allocation and use.
  4. 根据权利要求3所述的装置,其特征在于,所述分配单元,具体还用于:The device according to claim 3, wherein the allocating unit is further configured to:
    当所述共享内存池中存在至少两种不同长度的所述第二内存块时,从所述共享内存池中选取空闲的、长度大于且最接近于所述需求长度的第二内存块。 When there are at least two different lengths of the second memory block in the shared memory pool, an idle second memory block having a length greater than and closest to the required length is selected from the shared memory pool.
  5. 根据权利要求1至4任一所述的装置,其特征在于,所述装置还包括:The device according to any one of claims 1 to 4, wherein the device further comprises:
    第三获取单元,用于获取需要释放的内存块对应的内存地址和长度;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 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.
  6. 根据权利要求1至5任一所述的装置,其特征在于,所述至少两种不同长度的内存块包括w级不同长度的内存块,且第i+1级内存块的长度是第i级内存块的长度的q倍,第w级内存块的长度为所述预定长度,w≥2,1≤i≤w-1,q≥2且w、i、q均为整数。The device according to any one of claims 1 to 5, wherein the at least two memory blocks of different lengths comprise 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.
  7. 一种内存管理装置,其特征在于,所述装置包括:控制器和寄存器;A memory management device, characterized in that the device comprises: a controller and a register;
    所述寄存器用于存储一个或者一个以上的指令,所述指令用于实现一种内存管理方法;The register is configured to store one or more instructions for implementing a memory management method;
    所述方法包括:The method includes:
    获取预定大小的待分配内存;Obtaining a predetermined size of memory to be allocated;
    根据所述待分配内存创建共享内存池,所述共享内存池中包括将所述待分配内存划分得到的n个长度为预定长度的内存块,所述共享内存池用于提供至少两种不同长度的内存块的内存申请服务,所述至少两种不同长度中的每一种长度小于或等于所述预定长度,n≥2且n为正整数;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;
    获取内存申请所对应的需求长度,所述需求长度是所述至少两种不同长度中的一种;Obtaining a required length corresponding to the memory application, where the required length is one of the at least two different lengths;
    从所述共享内存池中获取一个长度为所述需求长度的内存块进行分配使用;Obtaining, by using the shared memory pool, a memory block of a length of the required length for allocation and use;
    所述控制器用于执行所述指令。The controller is operative to execute the instructions.
  8. 根据权利要求7所述的装置,其特征在于,所述寄存器还存储有用于执 行以下操作的指令:The apparatus according to claim 7, wherein said register is further stored for execution The instructions for the following operations:
    检测所述共享内存池中是否存在空闲的且长度为所述需求长度的第一内存块;Detecting, in the shared memory pool, whether there is a first memory block that is idle and has a length of the required length;
    若所述共享内存池中存在所述第一内存块,则将所述第一内存块进行分配使用;If 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.
  9. 根据权利要求8所述的装置,其特征在于,所述寄存器还存储有用于执行以下操作的指令:The apparatus of claim 8 wherein said register further stores instructions for performing the following operations:
    当所述共享内存池中不存在所述第一内存块时,从所述共享内存池中选取空闲的且长度大于所述需求长度的第二内存块;When 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;
    将所述第二内存块划分为m个内存块,所述m个内存块中包含长度为所述需求长度的内存块,m≥2且m为整数;Dividing the second memory block into m memory blocks, where the m memory blocks include a memory block having a length of the required length, m≥2 and m is an integer;
    从所述m个内存块中选取所述长度为所述需求长度的内存块进行分配使用;And selecting, from the m memory blocks, the memory block whose length is the required length for allocation and use;
    所述控制器还用于执行所述指令。The controller is also operative to execute the instructions.
  10. 根据权利要求9所述的装置,其特征在于,所述寄存器还存储有用于执行以下操作的指令:The apparatus of claim 9 wherein said register further stores instructions for performing the following operations:
    当所述共享内存池中存在至少两种不同长度的所述第二内存块时,从所述共享内存池中选取空闲的、长度大于且最接近于所述需求长度的第二内存块;When there are at least two different memory blocks of different lengths in the shared memory pool, select a second memory block that is free from the shared memory pool and has a length greater than and closest to the required length;
    所述控制器还用于执行所述指令。The controller is also operative to execute the instructions.
  11. 根据权利要求7至10任一所述的装置,其特征在于,所述寄存器还存储有用于执行以下操作的指令:The apparatus according to any one of claims 7 to 10, characterized in that said register further stores instructions for performing the following operations:
    获取需要释放的内存块对应的内存地址和长度;Get the memory address and length corresponding to the memory block that needs to be released;
    当所述需要释放的内存块的长度小于所述预定长度时,根据所述内存地址检测所述需要释放的内存块所属的目标内存块中的其它内存块是否空闲,所述目标内存块的长度是所述至少两种不同长度中的一种且所述目标内存块的长度大于所述需要释放的内存块的长度;When 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 a length of the memory block to be released;
    若所述其它内存块空闲,则将所述需要释放的内存块和所述其它内存块合 并为所述目标内存块,所述目标内存块的长度是所述至少两种不同长度中的一种;If the other memory block is idle, the memory block that needs to be released is combined with the other memory block And for the target memory block, 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.
  12. 根据权利要求7至11任一所述的装置,其特征在于,所述至少两种不同长度的内存块包括w级不同长度的内存块,且第i+1级内存块的长度是第i级内存块的长度的q倍,第w级内存块的长度为所述预定长度,w≥2,1≤i≤w-1,q≥2且w、i、q均为整数。The device according to any one of claims 7 to 11, wherein the at least two memory blocks of different lengths comprise memory blocks of different lengths of w, 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.
  13. 一种内存管理方法,其特征在于,所述方法包括:A memory management method, the method comprising:
    获取预定大小的待分配内存;Obtaining a predetermined size of memory to be allocated;
    根据所述待分配内存创建共享内存池,所述共享内存池中包括将所述待分配内存划分得到的n个长度为预定长度的内存块,所述共享内存池用于提供至少两种不同长度的内存块的内存申请服务,所述至少两种不同长度中的每一种长度小于或等于所述预定长度,n≥2且n为正整数;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;
    获取内存申请所对应的需求长度,所述需求长度是所述至少两种不同长度中的一种;Obtaining a required length corresponding to the memory application, where the required length is one of the at least two different lengths;
    从所述共享内存池中获取一个长度为所述需求长度的内存块进行分配使用。Obtaining a memory block of the required length from the shared memory pool for allocation.
  14. 根据权利要求13所述的方法,其特征在于,所述从所述共享内存池中获取一个长度为所述需求长度的内存块进行分配使用,包括:The method according to claim 13, wherein the obtaining, by using the shared memory pool, a memory block of a length of the required length for allocation, comprises:
    检测所述共享内存池中是否存在空闲的且长度为所述需求长度的第一内存块;Detecting, in the shared memory pool, whether there is a first memory block that is idle and has a length of the required length;
    若所述共享内存池中存在所述第一内存块,则将所述第一内存块进行分配使用。If the first memory block exists in the shared memory pool, the first memory block is allocated for use.
  15. 根据权利要求14所述的方法,其特征在于,所述检测所述共享内存池中是否存在空闲的且长度为所述需求长度的第一内存块之后,还包括:The method according to claim 14, wherein after detecting whether the first memory block of the required length is available in the shared memory pool, the method further includes:
    若所述共享内存池中不存在所述第一内存块,则从所述共享内存池中选取空闲的且长度大于所述需求长度的第二内存块; If 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;
    将所述第二内存块划分为m个内存块,所述m个内存块中包含长度为所述需求长度的内存块,m≥2且m为整数;Dividing the second memory block into m memory blocks, where the m memory blocks include a memory block having a length of the required length, m≥2 and m is an integer;
    从所述m个内存块中选取所述长度为所述需求长度的内存块进行分配使用。And selecting, from the m memory blocks, the memory block whose length is the required length for allocation and use.
  16. 根据权利要求15所述的方法,其特征在于,所述从所述共享内存池中选取空闲的且长度大于所述需求长度的第二内存块,包括:The method according to claim 15, wherein the selecting from the shared memory pool a second memory block that is free and longer than the required length comprises:
    当所述共享内存池中存在至少两种不同长度的所述第二内存块时,从所述共享内存池中选取空闲的、长度大于且最接近于所述需求长度的第二内存块。When there are at least two different lengths of the second memory block in the shared memory pool, an idle second memory block having a length greater than and closest to the required length is selected from the shared memory pool.
  17. 根据权利要求13至16任一所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 13 to 16, wherein the method further comprises:
    获取需要释放的内存块对应的内存地址和长度;Get the memory address and length corresponding to the memory block that needs to be released;
    当所述需要释放的内存块的长度小于所述预定长度时,根据所述内存地址检测所述需要释放的内存块所属的目标内存块中的其它内存块是否空闲,所述目标内存块的长度是所述至少两种不同长度中的一种且所述目标内存块的长度大于且最接近于所述需要释放的内存块的长度;When 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;
    若所述其它内存块空闲,则将所述需要释放的内存块和所述其它内存块合并为所述目标内存块。If the other memory block is idle, the memory block that needs to be released and the other memory block are merged into the target memory block.
  18. 根据权利要求13至17任一所述的方法,其特征在于,所述至少两种不同长度的内存块包括w级不同长度的内存块,且第i+1级内存块的长度是第i级内存块的长度的q倍,第w级内存块的长度为所述预定长度,w≥2,1≤i≤w-1,q≥2且w、i、q均为整数。 The method according to any one of claims 13 to 17, wherein the at least two memory blocks of different lengths comprise memory blocks of different lengths of w, 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.
PCT/CN2015/072535 2015-02-09 2015-02-09 Memory management device and method WO2016127291A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2015/072535 WO2016127291A1 (en) 2015-02-09 2015-02-09 Memory management device and method
CN201580075454.8A CN107209716B (en) 2015-02-09 2015-02-09 Memory management device and method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2015/072535 WO2016127291A1 (en) 2015-02-09 2015-02-09 Memory management device and method

Publications (1)

Publication Number Publication Date
WO2016127291A1 true WO2016127291A1 (en) 2016-08-18

Family

ID=56614242

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/072535 WO2016127291A1 (en) 2015-02-09 2015-02-09 Memory management device and method

Country Status (2)

Country Link
CN (1) CN107209716B (en)
WO (1) WO2016127291A1 (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110008021A (en) * 2019-03-05 2019-07-12 平安科技(深圳)有限公司 EMS memory management process, device, electronic equipment and computer readable storage medium
CN110427273A (en) * 2019-06-25 2019-11-08 平安科技(深圳)有限公司 Scheduling memory method, apparatus, equipment and storage medium
CN111143064A (en) * 2019-12-25 2020-05-12 浙江中控技术股份有限公司 Method and system for processing memory
CN111796902A (en) * 2019-04-08 2020-10-20 维塔科技(北京)有限公司 Method and device for switching shared memory area, storage medium and electronic equipment

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107766153A (en) * 2017-10-17 2018-03-06 华为技术有限公司 A kind of EMS memory management process and device
CN110858162B (en) * 2018-08-24 2022-09-23 华为技术有限公司 Memory management method and device and server
CN110287127A (en) * 2019-05-14 2019-09-27 江苏大学 A kind of Nonvolatile memory management method and system that more granularity multicores are expansible
CN113467930B (en) * 2021-05-31 2023-04-14 翱捷科技股份有限公司 Processing method and device for hardware management shared memory
CN114296917A (en) * 2021-12-23 2022-04-08 中汽创智科技有限公司 Memory allocation method and device and self-adaptive automobile open system architecture

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102650931A (en) * 2012-04-01 2012-08-29 华为技术有限公司 Method and system for writing data
CN103077126A (en) * 2012-12-24 2013-05-01 中兴通讯股份有限公司 Memory management method and device
CN103425592A (en) * 2013-08-05 2013-12-04 大唐移动通信设备有限公司 Memory management method and device for multiprocess system
CN103838859A (en) * 2014-03-19 2014-06-04 厦门雅迅网络股份有限公司 Method for reducing data copy among multiple processes under linux

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1181434C (en) * 2001-06-28 2004-12-22 华为技术有限公司 Adaptive dynamic memory management method
CN101329655B (en) * 2008-07-31 2011-09-28 北京天碁科技有限公司 Memory management method and device
CN101673246A (en) * 2009-08-06 2010-03-17 深圳市融创天下科技发展有限公司 High-efficient first-in first-out (FIFO) data pool reading and writing method
CN102455974A (en) * 2010-10-21 2012-05-16 上海宝信软件股份有限公司 High-speed internal memory application and release management system with controllable internal memory consumption and high-speed internal memory application release management method
CN102063385A (en) * 2010-12-23 2011-05-18 深圳市金宏威实业发展有限公司 Memory management method and system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102650931A (en) * 2012-04-01 2012-08-29 华为技术有限公司 Method and system for writing data
CN103077126A (en) * 2012-12-24 2013-05-01 中兴通讯股份有限公司 Memory management method and device
CN103425592A (en) * 2013-08-05 2013-12-04 大唐移动通信设备有限公司 Memory management method and device for multiprocess system
CN103838859A (en) * 2014-03-19 2014-06-04 厦门雅迅网络股份有限公司 Method for reducing data copy among multiple processes under linux

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110008021A (en) * 2019-03-05 2019-07-12 平安科技(深圳)有限公司 EMS memory management process, device, electronic equipment and computer readable storage medium
CN110008021B (en) * 2019-03-05 2024-05-28 平安科技(深圳)有限公司 Memory management method, memory management device, electronic equipment and computer readable storage medium
CN111796902A (en) * 2019-04-08 2020-10-20 维塔科技(北京)有限公司 Method and device for switching shared memory area, storage medium and electronic equipment
CN111796902B (en) * 2019-04-08 2024-03-19 维塔科技(北京)有限公司 Method and device for switching shared memory area, storage medium and electronic equipment
CN110427273A (en) * 2019-06-25 2019-11-08 平安科技(深圳)有限公司 Scheduling memory method, apparatus, equipment and storage medium
CN111143064A (en) * 2019-12-25 2020-05-12 浙江中控技术股份有限公司 Method and system for processing memory

Also Published As

Publication number Publication date
CN107209716B (en) 2020-04-21
CN107209716A (en) 2017-09-26

Similar Documents

Publication Publication Date Title
WO2016127291A1 (en) Memory management device and method
US8478926B1 (en) Co-processing acceleration method, apparatus, and system
EP3796168A1 (en) Information processing apparatus, information processing method, and virtual machine connection management program
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 (en) Cloud system memory data processing method, device, equipment and storage medium
US20130086352A1 (en) Dynamically configurable storage device
KR20130106392A (en) Allocation of memory buffers in computing system with multiple memory channels
KR101140914B1 (en) Technique for controlling computing resources
CN111104219A (en) Binding method, device, equipment and storage medium of virtual core and physical core
US8352702B2 (en) Data processing system memory allocation
KR20180089273A (en) Method and apparatus for implementing out-of-order resource allocation
US9697047B2 (en) Cooperation of hoarding memory allocators in a multi-process system
JP7506096B2 (en) Dynamic allocation of computing resources
KR20170055180A (en) Electronic Device having Multiple Operating Systems and Dynamic Memory Management Method thereof
WO2020259208A1 (en) Memory scheduling method and apparatus, device and storage medium
US20220253252A1 (en) Data processing method and apparatus
CN112162818B (en) Virtual memory allocation method and device, electronic equipment and storage medium
US20080005404A1 (en) Method for managing buffers pool and a system using the method
CN105677481A (en) Method and system for processing data and electronic equipment
CN104750614A (en) Memory management method and device
CN109167740B (en) Data transmission method and device
US20130247065A1 (en) Apparatus and method for executing multi-operating systems
US8607245B2 (en) Dynamic processor-set management
CN114327862A (en) Memory allocation method and device, electronic equipment and storage medium

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