CN111338981A - Memory fragmentation prevention method and system and storage medium - Google Patents

Memory fragmentation prevention method and system and storage medium Download PDF

Info

Publication number
CN111338981A
CN111338981A CN202010107315.1A CN202010107315A CN111338981A CN 111338981 A CN111338981 A CN 111338981A CN 202010107315 A CN202010107315 A CN 202010107315A CN 111338981 A CN111338981 A CN 111338981A
Authority
CN
China
Prior art keywords
memory block
idle
memory
length
idle memory
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.)
Granted
Application number
CN202010107315.1A
Other languages
Chinese (zh)
Other versions
CN111338981B (en
Inventor
谭冰
孟庆晓
吴闽华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Genew Technologies Co Ltd
Original Assignee
Shenzhen Genew Technologies Co Ltd
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 Shenzhen Genew Technologies Co Ltd filed Critical Shenzhen Genew Technologies Co Ltd
Priority to CN202010107315.1A priority Critical patent/CN111338981B/en
Publication of CN111338981A publication Critical patent/CN111338981A/en
Application granted granted Critical
Publication of CN111338981B publication Critical patent/CN111338981B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/10Providing a specific technical effect
    • G06F2212/1016Performance improvement
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/10Providing a specific technical effect
    • G06F2212/1041Resource optimization
    • G06F2212/1044Space efficiency improvement

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 discloses a memory fragmentation prevention method, a system and a storage medium, wherein the method comprises the steps of detecting whether a terminal has a spare memory block when receiving a request instruction for applying the spare memory block; when at least one idle memory block exists, determining the idle memory block to be used and the memory length of the idle memory block; when the memory length of the idle memory block to be used is larger than the application length, determining whether the idle memory block to be used is segmented or not; and if the difference value between the memory length of the idle memory block to be used and the application length is larger than the threshold value of the minimum memory block, dividing the idle memory block to be used into two blocks and using the two blocks. The invention aims to determine whether the idle memory blocks to be allocated are divided or not according to the minimum memory block threshold value, thereby ensuring that each idle memory block is effectively used, improving the utilization rate, and meanwhile, allocating the idle memory blocks from a low address or a high address according to an application scene, reducing the probability of the idle memory blocks of different sizes being mixed together, reducing the execution of blocking operation and improving the allocation efficiency.

Description

Memory fragmentation prevention method and system and storage medium
Technical Field
The invention relates to the technical field of computers, in particular to a memory fragment-preventing method, a memory fragment-preventing system and a memory medium.
Background
The existing heap memory technology allocates memory blocks according to the actual required length, and allocates the memory blocks sequentially from a low address or a high address. When the length of the memory block to be allocated is larger than the actual required length, the memory block to be allocated is fragmented, so that the memory block after fragmentation is too small to be allocated or allocation fails, the memory utilization rate is low, and memory space is wasted.
Accordingly, there is still a need for development and improvement of the prior art.
Disclosure of Invention
Based on this, it is necessary to provide a memory fragmentation prevention method, system and storage medium for solving the technical problems of low memory block utilization rate and space waste in the prior art, and the purpose is to determine whether an idle memory block to be allocated is partitioned according to a minimum memory block threshold value, thereby ensuring that each idle memory block is effectively used, improving the utilization rate, and meanwhile, allocating the idle memory blocks from a low address or from a high address according to an application scenario, reducing the probability of the size of the idle memory blocks being mixed together, reducing the execution of blocking operations, and improving the allocation efficiency.
In order to achieve the purpose, the invention adopts the following technical scheme:
a memory chipping prevention method comprises the following steps:
when receiving a request instruction for applying for a free memory block, detecting whether a terminal has the free memory block;
when detecting that the terminal has at least one idle memory block, determining the idle memory block to be used and the memory length of the idle memory block to be used according to the acquired application length;
when the memory length of the idle memory block to be used is greater than the application length, comparing the difference value between the memory length of the idle memory block to be used and the application length with a preset minimum memory block threshold value to determine whether the idle memory block to be used is segmented or not;
and if the difference value between the memory length of the idle memory block to be used and the application length is greater than a preset minimum memory block threshold value, dividing the idle memory block to be used into two blocks and using the two blocks.
The memory chipping prevention method further comprises the following steps:
and if the difference value between the memory length of the standby idle memory block and the application length is smaller than a preset minimum memory block threshold value, the standby idle memory block is not segmented and used.
The method for preventing fragmentation of a memory, wherein if a difference between the memory length of the idle memory block to be used and the application length is greater than a preset minimum memory block threshold, the method for preventing fragmentation of a memory divides the idle memory block to be used into two blocks and specifically includes:
if the difference value between the memory length of the idle memory block to be used and the application length is greater than a preset minimum memory block threshold value, dividing the idle memory block to be used into a first idle memory block and a second idle memory block; the memory length of the second idle memory block is equal to the memory length of the idle memory block to be used before segmentation, namely the application length;
and using the first free memory block and updating the state of the first free memory block to be a busy state.
The method for preventing fragmentation of a memory, wherein if a difference between the length of the memory of the idle memory block to be used and the application length is greater than a preset minimum memory block threshold, the method for preventing fragmentation of a memory comprises the following steps:
detecting whether a request instruction for releasing a currently used idle memory block is received in real time;
when a request instruction for releasing the currently used idle memory block is detected to be received, releasing the first idle memory block and updating the state of the first idle memory block to be an idle state.
The method for preventing fragmentation of a memory, wherein if a difference between the length of the memory of the idle memory block to be used and the application length is greater than a preset minimum memory block threshold, the method further comprises the following steps of dividing the idle memory block to be used into two blocks and using the two blocks:
judging whether the state of a third idle memory block adjacent to the first idle memory block is an empty state;
when the state of a third idle memory block adjacent to the first idle memory block is judged to be an empty state, the first idle block and the third idle memory block are automatically merged into a fourth idle memory block.
The memory fragmentation prevention method includes, when there are multiple idle memory blocks for a terminal, determining idle memory blocks to be used and memory lengths of the idle memory blocks to be used according to the obtained application length specifically includes:
acquiring the application length and the memory length of each idle memory block;
comparing the application length with the memory lengths of all idle memory blocks one by one, and acquiring the idle memory blocks with the application length being more than or equal to the application length as initial idle memory blocks;
when only one initial idle memory block is obtained, the initial idle memory block is a standby idle memory block and the memory size of the standby idle memory block is obtained;
when a plurality of initial idle memory blocks are obtained, all the initial idle memory blocks are sorted according to the memory length from small to large, the initial idle memory block corresponding to the first sorting is obtained as the idle memory block to be used, and the memory size of the idle memory block to be used is obtained at the same time.
The memory fragmentation prevention method includes that, when it is detected that the terminal has at least one idle memory block, determining the idle memory block to be used and the memory length of the idle memory block to be used according to the obtained application length further includes:
acquiring a preset length threshold value for distinguishing high and low address allocation;
when the application length is larger than the length threshold, determining an idle memory block from a memory high address;
and when the application length is smaller than the length threshold, determining an idle memory block from a memory low address.
The memory fragmentation prevention method is characterized in that the minimum memory block threshold is 512 bytes, and the length threshold includes one of 512 bytes, 1024 bytes, 2048 bytes, and 4096 bytes.
The invention also provides a system, which comprises a processor and a memory connected with the processor, wherein the memory stores a memory anti-fragmentation program, and the processor is used for realizing the steps in the memory anti-fragmentation method when executing.
The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores one or more programs, and the one or more programs are executable by one or more processors to implement the steps of the memory fragmentation prevention method described above.
Has the advantages that:
compared with the prior art, the invention provides a memory fragmentation prevention method, a system and a storage medium, wherein the method comprises the steps of detecting whether a terminal has a spare memory block or not when receiving a request instruction for applying for the spare memory block; when detecting that the terminal has at least one idle memory block, determining the idle memory block to be used and the memory length of the idle memory block to be used according to the acquired application length; when the memory length of the idle memory block to be used is greater than the application length, comparing the difference value between the memory length of the idle memory block to be used and the application length with a preset minimum memory block threshold value to determine whether the idle memory block to be used is segmented or not; and if the difference value between the memory length of the idle memory block to be used and the application length is greater than a preset minimum memory block threshold value, dividing the idle memory block to be used into two blocks and using the two blocks. The invention aims to determine whether the idle memory blocks to be allocated are divided or not according to the minimum memory block threshold value, thereby ensuring that each idle memory block is effectively used, improving the utilization rate, and meanwhile, allocating the idle memory blocks from a low address or a high address according to an application scene, reducing the probability of the idle memory blocks of different sizes being mixed together, reducing the execution of blocking operation and improving the allocation efficiency.
Drawings
Fig. 1 is a flowchart of a memory fragmentation prevention method according to the present invention.
Fig. 2 is a functional block diagram of the system of the present invention.
Detailed Description
In order to make the objects, technical solutions and effects of the present invention clearer and clearer, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The memory fragmentation-preventing method provided by the invention does not allocate the idle memory blocks according to the application length of the actual requirement, but searches the optimally matched idle memory blocks from all the idle memory blocks for use, and the idle memory blocks to be used can be divided only when the condition that the divided idle memory blocks which are not used are larger than the threshold value of the minimum memory block is met, so that each idle memory block before and after the division can be effectively used, and the utilization rate is improved. And when the idle memory blocks are allocated, the block addresses of the idle memory blocks to be used are selected according to the actually required application length, and are not fixedly allocated from a low address or always allocated from a high address.
Referring to fig. 1, fig. 1 is a flowchart of a memory fragmentation prevention method according to the present invention, it should be noted that the memory fragmentation prevention method according to the embodiment of the present invention is not limited to the steps and the sequence in the flowchart shown in fig. 1, and the steps in the flowchart may be added, removed, or changed in sequence according to different requirements.
As shown in fig. 1, the method for preventing the memory from being broken provided by the present invention includes the following steps:
and S10, when receiving the request instruction for applying the free memory block, detecting whether the terminal has the free memory block.
In this embodiment of the present invention, before step S10, a minimum memory block threshold value indicating whether the idle memory block to be used is divided is preset, where the minimum memory block threshold value is a length required by a common codec. The minimum memory block threshold includes, but is not limited to, one of 512 bytes, 1024 bytes, 2048 bytes, and 4096 bytes. In this embodiment, the minimum memory block threshold is preferably 512 bytes. The threshold value of the minimum memory block is set by determining the threshold value of the memory size allocated from the small address or the large address according to the statistical value of the memory size for each codec and the probability of using in the device, thus, the length (size) of the memory required to be allocated for each codec is counted to divide a plurality of limited memory block types, and the most suitable memory length is taken when the idle memory block to be used is allocated.
A length threshold for distinguishing between high and low addresses is also preset, and the length threshold includes one of 512 bytes, 1024 bytes, 2048 bytes, and 4096 bytes. For example, setting a length threshold to 2048 bytes, and when the application length 3000 bytes is greater than the length threshold 2048, determining an idle memory block from a memory high address; when the application length 2000 bytes is smaller than the length threshold 2048, the free memory block is determined from the low memory address. This partition allocation reduces the probability that large and small blocks of memory will occur simultaneously within the same block of memory.
Further, the request for free memory block may be a request for free memory block issued when an application is opened.
When receiving a request instruction for applying for the idle memory block, detecting whether the terminal has the idle memory block. That is to say, whether the terminal has an unused idle memory block or not, that is, the state of the idle memory block is an empty state.
If the state of the free memory block is busy, it indicates that the current free memory block is being used.
Therefore, when receiving the request instruction for applying for the free memory block, it is necessary to determine whether the terminal has a free memory block corresponding to the free state.
And feeding back a prompt of failure application when detecting that the terminal does not have the idle memory block in the empty state.
And S20, when the terminal is detected to have at least one idle memory block, determining the idle memory block to be used and the memory length of the idle memory block to be used according to the acquired application length.
In this embodiment, if it is detected that the terminal has only one idle memory block, the idle memory block is used as a standby idle memory block, and the memory length of the standby idle memory block is obtained.
If the terminal is detected to have a plurality of idle memory blocks, determining idle memory blocks to be used and the memory length of the idle memory blocks to be used according to the obtained application length. The specific process comprises the following steps:
acquiring the application length and the memory length of each idle memory block;
comparing the application length with the memory lengths of all idle memory blocks one by one, and acquiring the idle memory blocks with the application length being more than or equal to the application length as initial idle memory blocks;
when only one initial idle memory block is obtained, the initial idle memory block is a standby idle memory block and the memory size of the standby idle memory block is obtained;
when a plurality of initial idle memory blocks are obtained, all the initial idle memory blocks are sorted according to the memory length from small to large, the initial idle memory block corresponding to the first sorting is obtained as the idle memory block to be used, and the memory size of the idle memory block to be used is obtained at the same time.
That is to say, when there are multiple idle memory blocks, the idle memory block closest to the application length is found, so that the probability of fragment formation is reduced, and the space utilization rate is effectively improved.
Thus, the difference from the prior art is that, in the present invention, the idle memory blocks that satisfy the application length are searched, and instead of only searching the first idle memory block that satisfies the application length and is allocated and used, the idle memory block that best matches the application length is found according to the indexes of all the idle memory blocks. That is, the memory length of the matched free memory block is almost equal to the application length to be allocated. For example, while the length 2000, the first free memory block 4096 and the second free memory block 2048 are applied, the first free memory block 4096 is searched and allocated for use in the prior art, the present invention searches the two free memory blocks and determines the second free memory block 2048 closest to the length 2000 to be allocated for use. Therefore, reasonable utilization of the idle memory blocks is avoided, and space waste and fragmentation are effectively prevented.
S30, when the memory length of the idle memory block to be used is greater than the application length, comparing the difference between the memory length of the idle memory block to be used and the application length with the preset minimum memory block threshold value to determine whether the idle memory block to be used is segmented.
That is, after determining the idle memory blocks to be used based on step S20, in order to further improve the space utilization, it needs to be determined whether the idle memory blocks to be used need to be divided for use. Therefore, the 2 partitioned idle memory blocks can be effectively used currently or next time, and invalid fragments of the memory are prevented from being generated.
Of course, if the memory length of the idle memory block to be used is equal to the application length, the comparison operation is not required.
Therefore, when the memory length of the idle memory block to be used is greater than the application length, the difference between the memory length of the idle memory block to be used and the application length (i.e. the memory length of the idle memory block to be used-the application length) is calculated. And then acquiring a preset minimum memory block threshold, comparing the difference (absolute value) with the minimum memory block threshold, and determining whether the current idle memory block to be used needs to be divided and then used according to the comparison result.
S40, if the difference between the memory length of the idle memory block to be used and the application length is larger than the preset minimum memory block threshold value, the idle memory block to be used is divided into two blocks and used.
That is, step S40 specifically includes:
s41, if the difference between the memory length of the idle memory block to be used and the application length is greater than a preset minimum memory block threshold, dividing the idle memory block to be used into a first idle memory block and a second idle memory block; the memory length of the second idle memory block is equal to the memory length of the idle memory block to be used before segmentation, namely the application length;
s42, using the first free memory block and updating the state of the first free memory block to be busy.
Wherein the busy state represents that the current first free memory block is in a use state.
For example: if the memory length 4000-the application length 2048-1952 of the idle memory block to be used is greater than the minimum memory block threshold value, e.g., 512, the idle memory block to be used is divided into a first idle memory block 2048, and the first idle memory block and a second idle memory block 1952 are used in an empty state to serve as a spare for the idle memory block to be applied next time.
That is to say, if the difference between the memory length of the idle memory block to be used and the application length is greater than the preset minimum memory block threshold, dividing the idle memory block to be used into two blocks and using the two blocks includes:
detecting whether a request instruction for releasing a currently used idle memory block is received in real time;
when a request instruction for releasing the currently used idle memory block is detected to be received, releasing the first idle memory block and updating the state of the first idle memory block to be an idle state.
Wherein the release is paired with the application, for example, the release is performed when the application is closed without using the application.
Further, once the state of the first idle memory block is changed to an empty state, determining whether the state of a third idle memory block adjacent to the first idle memory block is an empty state; when the state of a third idle memory block adjacent to the first idle memory block is judged to be an empty state, the first idle block and the third idle memory block are automatically merged into a fourth idle memory block. Therefore, fragmentation can be prevented, the distributability rate of the memory blocks can be improved, and the probability of application distribution failure caused by the fact that the memory length of the idle memory blocks is smaller than the application length is greatly reduced.
For example, if the first idle memory block is in the busy state, the second idle memory block is in the empty state, the third idle memory block is in the empty state, and the fourth idle memory block is in the busy state, the second idle memory block and the third idle memory block are merged into one idle memory block, and the memory length of the idle memory block is the sum of the memory lengths of the second idle memory block and the third idle memory block.
And when the first idle memory block is in an empty state, the second idle memory block is in an empty state, the third idle memory block is in a busy state, and the fourth idle memory block is in a busy state, the first idle memory block and the second idle memory block are combined into an idle memory block, wherein the memory length of the idle memory block is the sum of the memory lengths of the first idle memory block and the second idle memory block.
If the first idle memory block is in an empty state, the second idle memory block is in a busy state, the third idle memory block is in an empty state, and the fourth idle memory block is in a busy state, the first idle memory block and the third idle memory block cannot be merged.
Thus, based on steps S10-S40, whether the idle memory blocks to be allocated are partitioned is determined according to the minimum memory block threshold, so as to ensure that each idle memory block is effectively used, improve the availability of the memory blocks, and allocate the idle memory blocks from a low address or a high address according to an application scenario, thereby reducing the probability that the idle memory blocks of different sizes are mixed together, and reducing the probability of partitioning the memory blocks.
Example two
Based on the above-mentioned memory fragmentation prevention method, the present invention also provides a system, as shown in fig. 2, where the system 100 includes a processor 11 and a storage 22 connected to the processor 11, and fig. 2 only shows some components of the system 100, but it should be understood that not all of the shown components are required to be implemented, and more or less components may be implemented instead.
The storage 22 may be an internal storage unit of the system 100, such as a memory of the system 100, in some embodiments. The memory 22 may also be an external storage device of the system 100 in other embodiments, such as a plug-in U-disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), etc. provided on the system 100. Further, the memory 22 may also include both internal storage units and external storage devices of the system 100. The memory 22 is used for storing application software installed in the system 100 and various types of data, such as the memory anti-fragmentation program code. The memory 22 may also be used to temporarily store data that has been output or is to be output. In one embodiment, the memory 22 has a memory fragmentation prevention program stored thereon, which can be executed by the processor 11 to implement the memory fragmentation prevention method of the present application, as described above.
The processor 11 may be, in some embodiments, a Central Processing Unit (CPU), a microprocessor, a mobile phone baseband processor or other data Processing chip, and is configured to run program codes stored in the memory 22 or process data, for example, execute the memory anti-fragmentation method, and the like, as described in the above method.
The present invention further provides a computer-readable storage medium, which stores one or more programs, where the one or more programs are executable by one or more processors (in this embodiment, the processor 11) to implement the steps in the memory fragmentation prevention method of the present invention, specifically the method described above.
In summary, the present invention provides a memory fragmentation prevention method, system and storage medium, the method includes detecting whether a terminal has a spare memory block when receiving a request instruction for applying for the spare memory block; when at least one idle memory block exists, determining the idle memory block to be used and the memory length of the idle memory block; when the memory length of the idle memory block to be used is larger than the application length, determining whether the idle memory block to be used is segmented or not; and if the difference value between the memory length of the idle memory block to be used and the application length is larger than the threshold value of the minimum memory block, dividing the idle memory block to be used into two blocks and using the two blocks. The invention aims to determine whether the idle memory blocks to be allocated are divided or not according to the minimum memory block threshold value, thereby ensuring that each idle memory block is effectively used, improving the utilization rate, and meanwhile, allocating the idle memory blocks from a low address or a high address according to an application scene, reducing the probability of the idle memory blocks of different sizes being mixed together, reducing the execution of blocking operation and improving the allocation efficiency.
Of course, it will be understood by those skilled in the art that all or part of the processes of the methods of the above embodiments may be implemented by a computer program instructing relevant hardware (such as a processor, a controller, etc.), and the program may be stored in a computer readable storage medium, and when executed, the program may include the processes of the above method embodiments. The storage medium may be a memory, a magnetic disk, an optical disk, etc.
It is to be understood that the invention is not limited to the examples described above, but that modifications and variations may be effected thereto by those of ordinary skill in the art in light of the foregoing description, and that all such modifications and variations are intended to be within the scope of the invention as defined by the appended claims.

Claims (10)

1. A memory chipping prevention method is characterized by comprising the following steps:
when receiving a request instruction for applying for a free memory block, detecting whether a terminal has the free memory block;
when detecting that the terminal has at least one idle memory block, determining the idle memory block to be used and the memory length of the idle memory block to be used according to the acquired application length;
when the memory length of the idle memory block to be used is greater than the application length, comparing the difference value between the memory length of the idle memory block to be used and the application length with a preset minimum memory block threshold value to determine whether the idle memory block to be used is segmented or not;
and if the difference value between the memory length of the idle memory block to be used and the application length is greater than a preset minimum memory block threshold value, dividing the idle memory block to be used into two blocks and using the two blocks.
2. The memory chipping prevention method according to claim 1, further comprising:
and if the difference value between the memory length of the standby idle memory block and the application length is smaller than a preset minimum memory block threshold value, the standby idle memory block is not segmented and used.
3. The method according to claim 1, wherein if the difference between the memory length of the idle memory block to be used and the application length is greater than a preset minimum memory block threshold, the dividing the idle memory block to be used into two blocks and using specifically includes:
if the difference value between the memory length of the idle memory block to be used and the application length is greater than a preset minimum memory block threshold value, dividing the idle memory block to be used into a first idle memory block and a second idle memory block; the memory length of the second idle memory block is equal to the memory length of the idle memory block to be used before segmentation, namely the application length;
and using the first free memory block and updating the state of the first free memory block to be a busy state.
4. The method according to claim 3, wherein if the difference between the memory length of the idle memory block to be used and the application length is greater than a preset minimum memory block threshold, the method for preventing fragmentation of a memory further comprises:
detecting whether a request instruction for releasing a currently used idle memory block is received in real time;
when a request instruction for releasing the currently used idle memory block is detected to be received, releasing the first idle memory block and updating the state of the first idle memory block to be an idle state.
5. The method according to claim 4, wherein if the difference between the memory length of the idle memory block to be used and the application length is greater than a preset minimum memory block threshold, the method further includes, after dividing the idle memory block to be used into two blocks and using the two blocks:
judging whether the state of a third idle memory block adjacent to the first idle memory block is an empty state;
when the state of a third idle memory block adjacent to the first idle memory block is judged to be an empty state, the first idle block and the third idle memory block are automatically merged into a fourth idle memory block.
6. The method according to claim 1, wherein, when there are multiple idle memory blocks in the terminal, the determining, according to the obtained application length, the memory length of the idle memory block to be used and the idle memory block to be used specifically includes:
acquiring the application length and the memory length of each idle memory block;
comparing the application length with the memory lengths of all idle memory blocks one by one, and acquiring the idle memory blocks with the application length being more than or equal to the application length as initial idle memory blocks;
when only one initial idle memory block is obtained, the initial idle memory block is a standby idle memory block and the memory size of the standby idle memory block is obtained;
when a plurality of initial idle memory blocks are obtained, all the initial idle memory blocks are sorted according to the memory length from small to large, the initial idle memory block corresponding to the first sorting is obtained as the idle memory block to be used, and the memory size of the idle memory block to be used is obtained at the same time.
7. The method according to claim 1, wherein when it is detected that the terminal has at least one idle memory block, determining the idle memory block to be used and the memory length of the idle memory block to be used according to the obtained application length further includes:
acquiring a preset length threshold value for distinguishing high and low address allocation;
when the application length is larger than the length threshold, determining an idle memory block from a memory high address;
and when the application length is smaller than the length threshold, determining an idle memory block from a memory low address.
8. The memory anti-fragmentation method of claim 7, wherein the minimum memory block threshold is 512 bytes and the length threshold comprises one of 512 bytes, 1024 bytes, 2048 bytes, and 4096 bytes.
9. A system comprising a processor and a memory coupled to the processor, the memory storing a memory anti-fragmentation program, the processor when executing is configured to implement the steps in the memory anti-fragmentation method of any of claims 1-8.
10. A computer-readable storage medium, storing one or more programs, the one or more programs being executable by one or more processors to perform the steps of the memory fragmentation prevention method of any of claims 1-8.
CN202010107315.1A 2020-02-21 2020-02-21 Memory fragmentation prevention method and system and storage medium Active CN111338981B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010107315.1A CN111338981B (en) 2020-02-21 2020-02-21 Memory fragmentation prevention method and system and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010107315.1A CN111338981B (en) 2020-02-21 2020-02-21 Memory fragmentation prevention method and system and storage medium

Publications (2)

Publication Number Publication Date
CN111338981A true CN111338981A (en) 2020-06-26
CN111338981B CN111338981B (en) 2022-11-08

Family

ID=71185567

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010107315.1A Active CN111338981B (en) 2020-02-21 2020-02-21 Memory fragmentation prevention method and system and storage medium

Country Status (1)

Country Link
CN (1) CN111338981B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112685333A (en) * 2020-12-28 2021-04-20 上海创功通讯技术有限公司 Heap memory management method and device
CN115658561A (en) * 2022-11-16 2023-01-31 石家庄科林电气股份有限公司 Power distribution terminal memory management method and device, electronic equipment and storage medium

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB0325788D0 (en) * 2003-11-05 2003-12-10 Ibm Memory allocation
CN1635482A (en) * 2003-12-29 2005-07-06 北京中视联数字系统有限公司 A memory management method for embedded system
US20050276275A1 (en) * 2004-06-15 2005-12-15 Alcatel Network statistics processing device
CN1963788A (en) * 2005-11-08 2007-05-16 中兴通讯股份有限公司 A managing method for EMS memory
CN101382916A (en) * 2007-09-06 2009-03-11 大唐移动通信设备有限公司 Method for managing embedded system memory
CN103885569A (en) * 2014-04-11 2014-06-25 珠海全志科技股份有限公司 Management method and device of memories
CN105159615A (en) * 2015-09-10 2015-12-16 上海斐讯数据通信技术有限公司 Dynamic memory control method and dynamic memory control system
CN105404590A (en) * 2015-11-10 2016-03-16 浪潮(北京)电子信息产业有限公司 Memory block combination method and system
CN105893269A (en) * 2016-03-31 2016-08-24 武汉虹信技术服务有限责任公司 Memory management method used in Linux system
CN109947560A (en) * 2019-02-25 2019-06-28 深圳市创联时代科技有限公司 A kind of EMS memory management process
CN110008140A (en) * 2019-03-11 2019-07-12 深圳市广和通无线股份有限公司 EMS memory management process, device, computer equipment and storage medium

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB0325788D0 (en) * 2003-11-05 2003-12-10 Ibm Memory allocation
CN1635482A (en) * 2003-12-29 2005-07-06 北京中视联数字系统有限公司 A memory management method for embedded system
US20050276275A1 (en) * 2004-06-15 2005-12-15 Alcatel Network statistics processing device
CN1963788A (en) * 2005-11-08 2007-05-16 中兴通讯股份有限公司 A managing method for EMS memory
CN101382916A (en) * 2007-09-06 2009-03-11 大唐移动通信设备有限公司 Method for managing embedded system memory
CN103885569A (en) * 2014-04-11 2014-06-25 珠海全志科技股份有限公司 Management method and device of memories
CN105159615A (en) * 2015-09-10 2015-12-16 上海斐讯数据通信技术有限公司 Dynamic memory control method and dynamic memory control system
CN105404590A (en) * 2015-11-10 2016-03-16 浪潮(北京)电子信息产业有限公司 Memory block combination method and system
CN105893269A (en) * 2016-03-31 2016-08-24 武汉虹信技术服务有限责任公司 Memory management method used in Linux system
CN109947560A (en) * 2019-02-25 2019-06-28 深圳市创联时代科技有限公司 A kind of EMS memory management process
CN110008140A (en) * 2019-03-11 2019-07-12 深圳市广和通无线股份有限公司 EMS memory management process, device, computer equipment and storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
卢萍等: "一种基于对象存储的文件系统的设计", 《计算机科学》 *
李志军: "面向嵌入式实时系统的动态内存管理方法研究", 《中国优秀硕士学位论文全文数据库(电子期刊)》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112685333A (en) * 2020-12-28 2021-04-20 上海创功通讯技术有限公司 Heap memory management method and device
CN112685333B (en) * 2020-12-28 2024-06-07 上海创功通讯技术有限公司 Heap memory management method and device
CN115658561A (en) * 2022-11-16 2023-01-31 石家庄科林电气股份有限公司 Power distribution terminal memory management method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN111338981B (en) 2022-11-08

Similar Documents

Publication Publication Date Title
US11042477B2 (en) Memory management using segregated free lists
US7124251B2 (en) Stack allocation system and method
CN103559054B (en) Realization, delet method and the device of intelligent terminal multi-operation system
US9977598B2 (en) Electronic device and a method for managing memory space thereof
CN111338981B (en) Memory fragmentation prevention method and system and storage medium
CN112612623B (en) Method and equipment for managing shared memory
WO2022151985A1 (en) Virtual memory-based data storage method and apparatus, device, and storage medium
CN112685333B (en) Heap memory management method and device
CN112579595A (en) Data processing method and device, electronic equipment and readable storage medium
US20240107647A1 (en) Control method, control device and lighting system
CN114327917A (en) Memory management method, computing device and readable storage medium
CN110750517B (en) Data processing method, device and equipment of local storage engine system
CN110806942A (en) Data processing method and device
US20160188453A1 (en) Memory pool management method for sharing memory pool among different computing units and related machine readable medium and memory pool management apparatus
CN110162395B (en) Memory allocation method and device
CN112199042B (en) Storage space management method, device, chip, equipment and storage medium
CN110688223A (en) Data processing method and related product
CN113849309B (en) Memory allocation method and device for business object
CN112346848A (en) Method, device and terminal for managing memory pool
CN110618946A (en) Stack memory allocation method, device, equipment and storage medium
US20060230246A1 (en) Memory allocation technique using memory resource groups
CN113986846A (en) Data processing method, system, device and storage medium
CN112463032A (en) Performance optimization method, system and device for deduplication module of storage system
CN112947863A (en) Method for combining storage spaces under Feiteng server platform
CN114003182B (en) Instruction interaction method and device, storage equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant