CN105975398A - Method for memory fragmentation management - Google Patents
Method for memory fragmentation management Download PDFInfo
- Publication number
- CN105975398A CN105975398A CN201510882915.4A CN201510882915A CN105975398A CN 105975398 A CN105975398 A CN 105975398A CN 201510882915 A CN201510882915 A CN 201510882915A CN 105975398 A CN105975398 A CN 105975398A
- Authority
- CN
- China
- Prior art keywords
- memory
- block
- free
- fragmentation
- allocation
- Prior art date
- Legal status (The legal status 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 status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/0223—User address space allocation, e.g. contiguous or non contiguous base addressing
- G06F12/023—Free address space management
- G06F12/0253—Garbage collection, i.e. reclamation of unreferenced memory
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
The invention provides a method for memory fragmentation management. The method comprises the steps that, memory space is distributed according to a memory distribution request during system running; a memory fragmentation degree is calculated, whether a calculation results exceeds a preset threshold is judged; and if the memory fragmentation degree exceeds the preset threshold, memory fragments can be searched and sorted. The method provided by the invention is characterized in that the memory fragments are searched and sorted based on the memory distribution in combination with the memory fragmentation degree, so that a utilization rate of the memory space is increased; the memory fragmentation is effectively reduced; and memory running stability is enhanced.
Description
Technical field
The present invention relates to field of computer technology, specifically a kind of memory fragmentation management method.
Background technology
Software program cannot determine required data volume to be processed completely when establishment.Program inevitably use the mode of dynamic memory distribution obtain internal memory and discharge this internal memory when being no longer necessary to and using.In general, the Memory Allocation in the operation time is the most stackable, and Memory Allocation is independent in time, so that fragment problems is difficult to solve.
The basic mode of Memory Allocation program waste internal memory has three kinds: overhead, internal fragmentation and external fragmentation.Memory Allocation program needs to store some data describing its distribution state, such as original position, size and the proprietary rights etc. of internal memory, thus produces extra expense when storage allocation.Additionally, Memory Allocation program needs to follow some basic Memory Allocation rules, such as, all of Memory Allocation must begin at the address that can be divided exactly (depending on processor architecture) by 4,8 or 16, when certain client asks the memory block of 43 bytes, he may obtain the even more byte of 44 bytes, 48 bytes, required size round up and the redundant space that produces just is internal fragmentation.When the difference being not used by occurring between storage allocation block, external fragmentation will be produced, such as, to three continuous print memory blocks of an application assigned, then that memory block making centre is released into as free memory, Memory Allocation program can be redistributed this middle memory block and use to other application programs, but the memory block being actually needed is just the biggest as this middle memory block, thus produces external fragmentation.
Although overhead and internal fragmentation can waste internal memory, but external fragmentation just can consume internal memory in a large number.Cause the allocation management method of the reason internal memory just of external fragmentation.Conventional memory allocation algorithm has and is suitable for allocation algorithm, time coexistence algorithm and space coexistence algorithm at first.
Summary of the invention
It is an object of the invention to provide a kind of memory fragmentation management method, by building Memory Allocation administrative model, in calculating for internal memory, data storage mode in internal memory, data update processing mode, use most suitable Memory Allocation Strategy and algorithm, make the interior generation existing and reducing fragmentation when distribution uses, utilize internal memory substantially.
The technical scheme is that
A kind of memory fragmentation management method, including the step of following sequence:
(1) in system operation, according to Memory Allocation request, memory headroom is allocated;
(2) internal memory degree of fragmentation is calculated, it is judged that whether result of calculation exceedes predetermined threshold value, the most then perform step (3), if it is not, then return step (1);
(3) carry out memory fragmentation collecting arranging.
Described memory fragmentation management method, described step (1), comprise the following steps:
A, will memory allocation pool represent less than the memory block chunk of 8K, and by Freelist linked list array, all chunk are managed, memory block block more than 8K represents, and with Block chained list, all block are managed, judge that Memory Allocation is asked the memory size of distribution whether more than 8K, the most then perform step b, if it is not, then perform step c;
B, redistribute a block for the request of described Memory Allocation, and this block is added in Block chained list;
C, search whether in Freelist linked list array exist be suitable for described Memory Allocation request chunk, the most then by described Memory Allocation request distribution to this chunk, if it is not, then perform step d;
D, described Memory Allocation is asked distribution memory size be added with the capacity of all chunk, obtain needing the total amount of memory of distribution, Block chained list searches whether there is the block being suitable for described total amount of memory, if, then the request of described Memory Allocation and all chunk are distributed to this block, if it is not, then redistribute a block for the request of described Memory Allocation and all chunk, and this block is added in Block chained list.
Described memory fragmentation management method, in described step (2), described calculates internal memory degree of fragmentation, uses below equation:
P=1-(L/A) * T
Wherein, P represents RAM fragmentation degree, L represent the maximum free time can the size of storage allocation block, A represents whole free memory size, T express time weight.
Described memory fragmentation management method, described step (3), comprise the following steps:
A, find out each section of free memory being managed between internal memory top and end;
If being discontinuous on address between certain two sections of free memory of b, but the capacity of one of them section has used the capacity of internal memory not less than the centre separated, then these two sections of free memories are labeled as close two section free memory;
If being continuous print on address between certain two sections of free memory, then these two sections of free memories are labeled as adjacent two section free memory;
C, for two sections of close free memories, centre is transferred to wherein one section of free memory by the storage content of internal memory, wherein another section of free memory is labeled as adjacent two section free memory with the middle one section of new free memory obtained with internal memory release;
D, for two sections of adjacent free memories, be integrated into new free memory block;
E, repeat the above steps, until all close or adjacent two section free memory being managed between internal memory top and end all arranges complete.
As shown from the above technical solution, the present invention is on the basis of Memory Allocation, in conjunction with RAM fragmentation degree, carries out memory fragmentation collecting arrangement, improves the utilization rate of memory headroom, effectively reduce RAM fragmentation, improve internal memory operation stability.
Accompanying drawing explanation
Fig. 1 is the method flow diagram of the present invention;
Fig. 2 is the Freelist linked list array structural representation of the present invention;
Fig. 3 is the Memory Allocation flow chart of the present invention.
Detailed description of the invention
The present invention is further illustrated below in conjunction with the accompanying drawings with specific embodiment.
As it is shown in figure 1, a kind of memory fragmentation management method, comprise the following steps:
S1, according to Memory Allocation Strategy to Memory Allocation request carry out memory headroom distribution;
Definition Memory Allocation request is Req, and memory allocation pool is Pool, and in Pool, the memory block less than 8K is referred to as chunk, manages with Freelist linked list array, and the memory block more than 8K is referred to as block, manages with Block chained list.Freelist linked list array form is as shown in Figure 2.
Memory Allocation Strategy is as follows:
First determine whether that Req is either with or without more than 8K, it's not true just searches either with or without the chunk that can use in Freelist linked list array, without finding the chunk that can use, just this Req size plus all of chunk size, Block chained list is searched either with or without the available block meeting aforementioned size sum, if it did not, just redistribute a block.If Req has exceeded 8K, just redistribute the block of a Req size, be added in Block chained list, as shown in Figure 3.
S2, RAM fragmentation degree when showing that system is run according to RAM fragmentation level calculating method, judge whether to need to carry out memory fragmentation according to result of calculation and collect and arrange;
RAM fragmentation degree computing formula is as follows:
RAM fragmentation degree=1-free memory occupies ratio
Assuming that the maximum free time can the size of storage allocation block LARGEST_free_block be L, the size of whole free memory All_free_memory is A, and it is J that free memory occupies ratio, then have:
J=L/A
Considering that RAM fragmentation degree is relevant with the time, be adjusted so above-mentioned formula needs to add time weighting T, after adjustment, free memory occupies the computational methods of ratio and is:
J=(L/A) * T
Assume that RAM fragmentation degree is P, then RAM fragmentation degree computing formula is as follows:
P=1-J
When P value exceedes default threshold value, need to carry out memory fragmentation collecting to arrange.
S3, combine method for sorting memory fragmentation is carried out conclude management;
Defining four pointer: MSTART and point to the top being managed internal memory, MEND points to the end being managed internal memory, MBREAK point between MSTART and MEND with internal memory, PFREE points to the free memory between MSTART and MEND.
Update PFREE and MBREAK pointer, the internal memory between MSTART and MEND is circulated and inquires after.Judge that the free memory between MSTART and MEND is the most neighbouring according to PFREE and MBREAK pointer position, the most neighbouring free memory is linked together, it will be marked as a free memory block.
Present invention can apply to power system and run monitoring center, improve internal memory service efficiency, improve system performance.
The above embodiment is only to be described the preferred embodiment of the present invention; not the scope of the present invention is defined; on the premise of designing spirit without departing from the present invention; various deformation that technical scheme is made by those of ordinary skill in the art and improvement, all should fall in the protection domain that claims of the present invention determines.
Claims (4)
1. a memory fragmentation management method, it is characterised in that include the step of following sequence:
(1) in system operation, according to Memory Allocation request, memory headroom is allocated;
(2) internal memory degree of fragmentation is calculated, it is judged that whether result of calculation exceedes predetermined threshold value, the most then perform step (3), if it is not, then return step (1);
(3) carry out memory fragmentation collecting arranging.
Memory fragmentation management method the most according to claim 1, it is characterised in that described step (1), comprises the following steps:
A, will memory allocation pool represent less than the memory block chunk of 8K, and by Freelist linked list array, all chunk are managed, memory block block more than 8K represents, and with Block chained list, all block are managed, judge that Memory Allocation is asked the memory size of distribution whether more than 8K, the most then perform step b, if it is not, then perform step c;
B, redistribute a block for the request of described Memory Allocation, and this block is added in Block chained list;
C, search whether in Freelist linked list array exist be suitable for described Memory Allocation request chunk, the most then by described Memory Allocation request distribution to this chunk, if it is not, then perform step d;
D, described Memory Allocation is asked distribution memory size be added with the capacity of all chunk, obtain needing the total amount of memory of distribution, Block chained list searches whether there is the block being suitable for described total amount of memory, if, then the request of described Memory Allocation and all chunk are distributed to this block, if it is not, then redistribute a block for the request of described Memory Allocation and all chunk, and this block is added in Block chained list.
Memory fragmentation management method the most according to claim 1, it is characterised in that in described step (2), described calculates internal memory degree of fragmentation, uses below equation:
P=1-(L/A) * T
Wherein, P represents RAM fragmentation degree, L represent the maximum free time can the size of storage allocation block, A represents whole free memory size, T express time weight.
Memory fragmentation management method the most according to claim 1, it is characterised in that described step (3), comprises the following steps:
A, find out each section of free memory being managed between internal memory top and end;
If being discontinuous on address between certain two sections of free memory of b, but the capacity of one of them section has used the capacity of internal memory not less than the centre separated, then these two sections of free memories are labeled as close two section free memory;
If being continuous print on address between certain two sections of free memory, then these two sections of free memories are labeled as adjacent two section free memory;
C, for two sections of close free memories, centre is transferred to wherein one section of free memory by the storage content of internal memory, wherein another section of free memory is labeled as adjacent two section free memory with the middle one section of new free memory obtained with internal memory release;
D, for two sections of adjacent free memories, be integrated into new free memory block;
E, repeat the above steps, until all close or adjacent two section free memory being managed between internal memory top and end all arranges complete.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510882915.4A CN105975398A (en) | 2015-12-07 | 2015-12-07 | Method for memory fragmentation management |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510882915.4A CN105975398A (en) | 2015-12-07 | 2015-12-07 | Method for memory fragmentation management |
Publications (1)
Publication Number | Publication Date |
---|---|
CN105975398A true CN105975398A (en) | 2016-09-28 |
Family
ID=56988274
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510882915.4A Pending CN105975398A (en) | 2015-12-07 | 2015-12-07 | Method for memory fragmentation management |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105975398A (en) |
Cited By (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106708746A (en) * | 2016-12-30 | 2017-05-24 | 郑州云海信息技术有限公司 | On-line memory defragmentation method and device |
CN109002258A (en) * | 2018-06-27 | 2018-12-14 | 郑州云海信息技术有限公司 | NameSpace distribution method, system and equipment and storage medium in solid state hard disk |
WO2018228344A1 (en) * | 2017-06-16 | 2018-12-20 | 深圳市万普拉斯科技有限公司 | Internal memory compaction method and apparatus, electronic device and readable storage medium |
CN110162483A (en) * | 2018-02-12 | 2019-08-23 | 上海寒武纪信息科技有限公司 | Static memory scrap cleaning method, device, computer equipment and storage medium |
CN111078587A (en) * | 2019-12-10 | 2020-04-28 | Oppo(重庆)智能科技有限公司 | Memory allocation method and device, storage medium and electronic equipment |
CN111897493A (en) * | 2020-07-15 | 2020-11-06 | 杭州海康威视系统技术有限公司 | Storage space management method and device, electronic equipment and storage medium |
CN111930739A (en) * | 2020-06-22 | 2020-11-13 | 中国建设银行股份有限公司 | Method, system, device and storage medium for automatic processing of tablespace fragmentation |
CN112363828A (en) * | 2020-10-30 | 2021-02-12 | 北京罗克维尔斯科技有限公司 | Memory fragment management method and device, vehicle-mounted system and vehicle |
CN113535725A (en) * | 2021-07-12 | 2021-10-22 | 中国工商银行股份有限公司 | Database storage space optimization method and device, electronic equipment and storage medium |
CN115185981A (en) * | 2022-09-14 | 2022-10-14 | 吉奥时空信息技术股份有限公司 | Data duplication checking method and device considering super-large table |
CN117632379A (en) * | 2024-01-25 | 2024-03-01 | 大连高德瑞信科技有限公司 | JAVA memory stack data analysis method and system |
CN118708502A (en) * | 2024-08-28 | 2024-09-27 | 深圳市云希谷科技有限公司 | Method for improving generation of large amount of memory fragments in use of map heap under freeRTOS |
CN118708502B (en) * | 2024-08-28 | 2024-11-08 | 深圳市云希谷科技有限公司 | Method for improving generation of large amount of memory fragments in use of map heap under freeRTOS |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101122883A (en) * | 2006-08-09 | 2008-02-13 | 中兴通讯股份有限公司 | Memory allocation method for avoiding RAM fragmentation |
CN101470665A (en) * | 2007-12-27 | 2009-07-01 | Tcl集团股份有限公司 | Method and system for internal memory management of application system without MMU platform |
CN101515247A (en) * | 2009-03-30 | 2009-08-26 | 福建星网锐捷网络有限公司 | Method and device for monitoring memory |
CN103389948A (en) * | 2012-05-10 | 2013-11-13 | 索尼公司 | Device and method for managing memorizer and electronic device |
US20150220268A1 (en) * | 2014-02-05 | 2015-08-06 | Sandisk Technologies Inc. | Storage Module and Host Device for Storage Module Defragmentation |
-
2015
- 2015-12-07 CN CN201510882915.4A patent/CN105975398A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101122883A (en) * | 2006-08-09 | 2008-02-13 | 中兴通讯股份有限公司 | Memory allocation method for avoiding RAM fragmentation |
CN101470665A (en) * | 2007-12-27 | 2009-07-01 | Tcl集团股份有限公司 | Method and system for internal memory management of application system without MMU platform |
CN101515247A (en) * | 2009-03-30 | 2009-08-26 | 福建星网锐捷网络有限公司 | Method and device for monitoring memory |
CN103389948A (en) * | 2012-05-10 | 2013-11-13 | 索尼公司 | Device and method for managing memorizer and electronic device |
US20150220268A1 (en) * | 2014-02-05 | 2015-08-06 | Sandisk Technologies Inc. | Storage Module and Host Device for Storage Module Defragmentation |
Cited By (20)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106708746B (en) * | 2016-12-30 | 2019-12-31 | 苏州浪潮智能科技有限公司 | Online memory defragmentation method and device |
CN106708746A (en) * | 2016-12-30 | 2017-05-24 | 郑州云海信息技术有限公司 | On-line memory defragmentation method and device |
WO2018228344A1 (en) * | 2017-06-16 | 2018-12-20 | 深圳市万普拉斯科技有限公司 | Internal memory compaction method and apparatus, electronic device and readable storage medium |
CN110162483A (en) * | 2018-02-12 | 2019-08-23 | 上海寒武纪信息科技有限公司 | Static memory scrap cleaning method, device, computer equipment and storage medium |
CN110162483B (en) * | 2018-02-12 | 2020-10-20 | 上海寒武纪信息科技有限公司 | Static memory defragmentation method, device, computer equipment and storage medium |
CN109002258A (en) * | 2018-06-27 | 2018-12-14 | 郑州云海信息技术有限公司 | NameSpace distribution method, system and equipment and storage medium in solid state hard disk |
CN111078587B (en) * | 2019-12-10 | 2022-05-06 | Oppo(重庆)智能科技有限公司 | Memory allocation method and device, storage medium and electronic equipment |
CN111078587A (en) * | 2019-12-10 | 2020-04-28 | Oppo(重庆)智能科技有限公司 | Memory allocation method and device, storage medium and electronic equipment |
CN111930739A (en) * | 2020-06-22 | 2020-11-13 | 中国建设银行股份有限公司 | Method, system, device and storage medium for automatic processing of tablespace fragmentation |
CN111897493A (en) * | 2020-07-15 | 2020-11-06 | 杭州海康威视系统技术有限公司 | Storage space management method and device, electronic equipment and storage medium |
CN111897493B (en) * | 2020-07-15 | 2023-03-10 | 杭州海康威视系统技术有限公司 | Storage space management method and device, electronic equipment and storage medium |
CN112363828B (en) * | 2020-10-30 | 2024-01-12 | 北京罗克维尔斯科技有限公司 | Memory fragment management method and device, vehicle-mounted system and vehicle |
CN112363828A (en) * | 2020-10-30 | 2021-02-12 | 北京罗克维尔斯科技有限公司 | Memory fragment management method and device, vehicle-mounted system and vehicle |
CN113535725A (en) * | 2021-07-12 | 2021-10-22 | 中国工商银行股份有限公司 | Database storage space optimization method and device, electronic equipment and storage medium |
CN115185981A (en) * | 2022-09-14 | 2022-10-14 | 吉奥时空信息技术股份有限公司 | Data duplication checking method and device considering super-large table |
CN115185981B (en) * | 2022-09-14 | 2022-11-25 | 吉奥时空信息技术股份有限公司 | Data duplication checking method and device considering super-large table |
CN117632379A (en) * | 2024-01-25 | 2024-03-01 | 大连高德瑞信科技有限公司 | JAVA memory stack data analysis method and system |
CN117632379B (en) * | 2024-01-25 | 2024-03-26 | 大连高德瑞信科技有限公司 | JAVA memory stack data analysis method and system |
CN118708502A (en) * | 2024-08-28 | 2024-09-27 | 深圳市云希谷科技有限公司 | Method for improving generation of large amount of memory fragments in use of map heap under freeRTOS |
CN118708502B (en) * | 2024-08-28 | 2024-11-08 | 深圳市云希谷科技有限公司 | Method for improving generation of large amount of memory fragments in use of map heap under freeRTOS |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105975398A (en) | Method for memory fragmentation management | |
US11048442B2 (en) | Scalable in-memory object storage system using hybrid memory devices | |
US10209908B2 (en) | Optimization of in-memory data grid placement | |
CN102385554B (en) | Method for optimizing duplicated data deletion system | |
CN105512129B (en) | A kind of searching mass data method and device, mass data storage means and system | |
CN105302692A (en) | Internal and external parameters based database connection pool monitoring and management method and apparatus | |
EP3963853B1 (en) | Optimizing storage and retrieval of compressed data | |
CN109828790B (en) | Data processing method and system based on Shenwei heterogeneous many-core processor | |
TWI493446B (en) | Method and apparatus for managing memory | |
CN104572505A (en) | System and method for ensuring eventual consistency of mass data caches | |
CN114048025A (en) | Streaming data heterogeneous computing memory optimization method based on dynamic telescopic memory pool | |
CN108093024B (en) | Classified routing method and device based on data frequency | |
CN103778222A (en) | File storage method and system for distributed file system | |
CN105554069B (en) | A kind of big data processing distributed cache system and its method | |
CN112650577A (en) | Memory management method and device | |
CN104050189B (en) | The page shares processing method and processing device | |
CN109144666A (en) | A kind of method for processing resource and system across cloud platform | |
CN104516821A (en) | Memory management method and memory management device | |
CN107861819B (en) | Cache group load balancing method and device and computer readable storage medium | |
CN111190737A (en) | Memory allocation method for embedded system | |
CN112383628B (en) | Storage gateway resource allocation method based on streaming storage | |
CN103365797B (en) | Physical memory page distribution method and computer system | |
CN107168804A (en) | A kind of memory source management method and system | |
CN114238481A (en) | Distributed real-time data importing device | |
Ramakrishna et al. | Smart dynamic memory allocator for embedded systems |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20160928 |
|
RJ01 | Rejection of invention patent application after publication |