CN103186469A - Memory allocation method and device, and memory recovery method - Google Patents

Memory allocation method and device, and memory recovery method Download PDF

Info

Publication number
CN103186469A
CN103186469A CN2011104467832A CN201110446783A CN103186469A CN 103186469 A CN103186469 A CN 103186469A CN 2011104467832 A CN2011104467832 A CN 2011104467832A CN 201110446783 A CN201110446783 A CN 201110446783A CN 103186469 A CN103186469 A CN 103186469A
Authority
CN
China
Prior art keywords
memory
internal memory
class
capacity
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
Application number
CN2011104467832A
Other languages
Chinese (zh)
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.)
Shanghai Pateo Electronic Equipment Manufacturing Co Ltd
Original Assignee
Shanghai Pateo Electronic Equipment Manufacturing 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 Shanghai Pateo Electronic Equipment Manufacturing Co Ltd filed Critical Shanghai Pateo Electronic Equipment Manufacturing Co Ltd
Priority to CN2011104467832A priority Critical patent/CN103186469A/en
Publication of CN103186469A publication Critical patent/CN103186469A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Memory System (AREA)

Abstract

The invention discloses a memory allocation method, a memory allocation device and a memory recovery method. The memory allocation method comprises the following steps: comparing a system allocation parameter with required capacity in an obtained memory allocation request; if the required capacity is less than or equal to the system allocation parameter, allocating a first type of memory, and setting a using state for the first type of memory which is allocated, wherein the capacity of the first type of memory is preset, and is matched with the required capacity in the memory allocation request; and if the required capacity is greater than the system allocation parameter, allocating a second type of memory with the required capacity, and setting a using state for the second type of memory which is allocated. According to the technical scheme, memory fragments are reduced, and the working efficiency of a system and the performance of the memory are improved.

Description

The recovery method of memory allocation method and device, internal memory
Technical field
The present invention relates to the technical field of Memory Allocation, especially a kind of memory allocation method and device, the recovery method of internal memory.
Background technology
Internal memory is the passage that connects CPU and other equipment, plays the effect of buffering and exchanges data.(for example, the CPU working procedure) need read data from external memory storages such as hard disks when CPU works, but because hard disk this " warehouse " is too big, add from CPU also very " away from ", the transportation " raw material " data speed just slow, cause the production efficiency of CPU to be had a greatly reduced quality.In order to address this problem, between CPU and external memory storage, built " goods kept in stock outside account "-internal memory.
The distribution of internal memory and reclaim mechanism are normally at present: when the program of CPU operation need be used internal memory at every turn, to internal memory of system's application (can be called the Memory Allocation request), system distributes the internal memory that is complementary according to the data volume of this secondary program operation (also can regard the size of the internal memory that the program application obtains as), program is service data in the internal memory of this distribution, and after operation finishes internal memory is exchanged to system; When following secondary program was moved, system redistributed and reclaims internal memory again according to aforesaid way.Concrete Memory Allocation and the mechanism of recovery can be the Chinese patent application of CN 102012870A with reference to publication number.
Internal memory is a continuous storage space, and when carrying out Memory Allocation, the storage space of internal memory is continuous dispensing, but internal memory is difficult to form continuous storage space after reclaiming.Since varying in size of the internal memory that different programs is obtained, so be easy to cause memory fragmentation after the internal memory recovery, influence the use of internal memory.In addition, the distribution that system does not stop and recovery internal memory also can influence the work efficiency of system, and influence the performance of internal memory.
Therefore how to reduce memory fragmentation, improve the work efficiency of system and the performance of internal memory and become one of present problem demanding prompt solution.
Summary of the invention
The problem that the present invention solves is that memory fragmentation of the prior art is more, system works inefficiency, the problem that internal memory performance is not high.
For addressing the above problem, technical scheme of the present invention provides a kind of memory allocation method, comprising:
Demand capacity in the Memory Allocation request of comparison system allocation of parameters and acquisition;
If described demand capacity is less than or equal to described system assignment parameter, then distributes first kind internal memory, and be the first kind memory setting use state of described distribution; The capacity of described first kind internal memory be preset and be complementary with demand capacity in the described Memory Allocation request;
If described demand capacity greater than described system assignment parameter, is then distributed the second class internal memory of described demand capacity, and the second class memory setting use state for distributing.
Optionally, described distribution first kind internal memory comprises:
If have the idle first kind internal memory that has distributed, then distribute the first kind internal memory that has distributed of this free time; Otherwise from Installed System Memory, distribute first kind internal memory.
Optionally, the described first kind internal memory that distributes from Installed System Memory comprises: each big first kind internal memory such as grade that distributes predetermined number from described Installed System Memory, the first kind internal memory of described predetermined number is with the form storage of chained list.
Optionally, the second class internal memory of the described demand capacity of described distribution comprises:
If have the idle second class internal memory that has distributed, then distribute the second class internal memory that has distributed of this free time; Otherwise from Installed System Memory, distribute the second class internal memory.
Optionally, the second class internal memory that has distributed of described this free time of distribution comprises: if the difference of the capacity of described demand capacity and the second class internal memory that has distributed of this free time is greater than described system assignment parameter, then according to described demand capacity should the free time the second class internal memory that has distributed cut into the second new class internal memory and distribution.
Optionally, the second class internal memory that distributes from described Installed System Memory is with the form storage of chained list.
Optionally, exist in the chained list in described second class and sort according to size.
Optionally, the capacity of described first kind internal memory be default and with comprising that demand capacity in the described Memory Allocation request is complementary: with described demand capacity based on the upwards align capacity of definite first kind internal memory of presetting and being complementary with described demand capacity of predetermined bite.
For addressing the above problem, technical scheme of the present invention also provides a kind of Memory Allocation device, comprising:
Judging unit is in order to the demand capacity in the Memory Allocation request of comparison system allocation of parameters and acquisition;
Allocation units are configured to distribute first kind internal memory when the described demand capacity of described judgment unit judges is less than or equal to described system assignment parameter, and be the first kind memory setting use state of described distribution; The capacity of described first kind internal memory is preset and is complementary with described demand capacity; During greater than described system assignment parameter, distribute the second class internal memory of described demand capacity in the described demand capacity of described judgment unit judges, and be that the second class memory setting of described distribution uses state.
For addressing the above problem, technical scheme of the present invention also provides a kind of recovery method of internal memory, comprising:
Based on the capacity of the internal memory that uses, described internal memory is recycled to described first kind internal memory or the second class internal memory, and resets the use state of described first kind internal memory or the second class internal memory.
Compared with prior art, the present invention has the following advantages:
Determine that based on the demand capacity in the Memory Allocation request and system assignment parameter the internal memory of this sub-distribution is the internal memory of fixed length or elongated internal memory.If fixed length, then distribute first kind internal memory; If elongated, then distribute the second class internal memory.With fixed length and the elongated storage allocation that combines, not only satisfied the demand of program, and improved the performance of total system.
Adopt memory pool technique, the internal memory of a plurality of fixed length of disposable distribution with the chained list management, and arranges its use state.For elongated internal memory, the elongated internal memory of distribution is managed with chained list, and its use state also is set.This not only can reduce memory fragmentation, and is beneficial to management.
Before storage allocation, whether there be first kind internal memory or the second class internal memory of the free time that is complementary in the first kind internal memory that retrieval has earlier distributed or the second class internal memory, if existence, the then first kind internal memory of this free time that is complementary of priority allocation or the second class internal memory.This not only reduces the consumption to new internal memory, reduces the distribution number of times to new internal memory, and improves the utilization factor of the internal memory that has distributed.
The internal memory that uses is recycled to first kind internal memory or the second class internal memory according to its capacity, realizes the use repeatedly of internal memory with this.This not only reduces the number of times of Memory Allocation, improves the work efficiency of system, and improves the utilization factor of internal memory, reduces memory fragmentation.
Description of drawings
Fig. 1 is the process flow diagram of the memory allocation method that provides of the embodiment of the invention;
Fig. 2 is the structural representation of the internal memory that provides of the embodiment of the invention;
Fig. 3 is the structural representation of the first kind internal memory that provides of the embodiment of the invention;
Fig. 4 is the structural representation of the second class internal memory that provides of the embodiment of the invention;
Fig. 5 is the structural drawing of the Memory Allocation device that provides of the embodiment of the invention.
Embodiment
For above-mentioned purpose of the present invention, feature and advantage can more be become apparent, below in conjunction with accompanying drawing the specific embodiment of the present invention is described in detail.
Set forth detail in the following description so that fully understand the present invention.But the present invention can be different from alternate manner described here and implements with multiple, and those skilled in the art can do similar popularization under the situation of intension of the present invention.Therefore the present invention is not subjected to the restriction of following public embodiment.
Fig. 1 is the process flow diagram of the memory allocation method that provides of the embodiment of the invention, describes in detail below in conjunction with Fig. 1.
Step S1, the demand capacity in the Memory Allocation request of comparison system allocation of parameters and acquisition;
Step S2 if described demand capacity is less than or equal to described system assignment parameter, then distributes first kind internal memory, and is the first kind memory setting use state of described distribution; The capacity of described first kind internal memory be preset and be complementary with demand capacity in the described Memory Allocation request;
Step S3, if described demand capacity greater than described system assignment parameter, is then distributed the second class internal memory of described demand capacity, and the second class memory setting use state for distributing.
Among the described step S1, program need be obtained internal memory depositing the data of operation in operational process, so during the program operation, sends the Memory Allocation request to system, and the program of carrying is moved the capacity (demand capacity) of described internal memory in the described Memory Allocation request.
After system obtains the Memory Allocation request, compare based on the demand capacity that wherein comprises (also can be that system is according to the capacity of the described internal memory of operation needs calculation procedure of program) and system assignment parameter, and result based on the comparison carries out follow-up Memory Allocation.
Described system assignment parameter is predetermined value, usually value 256 bytes.In the specific implementation, can arrange according to actual needs.
Among the described step S2, if described demand capacity is less than or equal to described system assignment parameter, then distribute first kind internal memory, concrete can be:
Described distribution first kind internal memory comprises: if there is the idle first kind internal memory that has distributed, then distribute the first kind internal memory that has distributed of this free time; Otherwise from Installed System Memory, distribute first kind internal memory.Generally, Installed System Memory is the internal memory that distributes for total system; First kind internal memory can be called the fixed length memory pool, after distributing from Installed System Memory, generally no longer returns to Installed System Memory.
The described first kind internal memory that distributes from Installed System Memory comprises: each big first kind internal memory such as grade that distributes predetermined number from described Installed System Memory, the first kind internal memory of described predetermined number is with the form storage of chained list.For example, according to the demand capacity (8 byte) of the required internal memory of this secondary program, once from Installed System Memory, distribute the first kind internal memory of the described demand capacity of predetermined number (100) (8 byte).
The capacity of described first kind internal memory is preset, and be complementary with the demand capacity in the described Memory Allocation request, definite mode of the capacity of described first kind internal memory can be that upwards alignment is definite based on predetermined bite with the demand capacity in the described Memory Allocation request, and the demand capacity in the capacity of described first kind internal memory and the described Memory Allocation request is complementary.Described predetermined bite can be 4 bytes.For example, the demand capacity in the described Memory Allocation request is 3 bytes, based on predetermined bite (4 byte) upwards the capacity of the first kind internal memory that is complementary of the demand capacity with in the described Memory Allocation request determined of alignment be 4 bytes.
Can be for the first kind memory setting that has used has used sign for the first kind memory setting of described distribution uses state, also can be not use sign for untapped first kind memory setting.During with storage of linked list first kind internal memory, can use pointer to indicate used or untapped first kind internal memory.
Among the described step S2, if described demand capacity greater than described system assignment parameter, is then distributed the second class internal memory of the demand capacity in the described Memory Allocation request, when specifically implementing can be:
The second class internal memory of the demand capacity in the described Memory Allocation request of described distribution comprises: if there is the idle second class internal memory that has distributed, then distribute the second class internal memory that has distributed of this free time; Otherwise from Installed System Memory, distribute the second class internal memory.
The second class internal memory that has distributed of described this free time of distribution comprises, the difference of the capacity of the second class internal memory that has distributed of the demand capacity in the described Memory Allocation request and this free time is greater than described system assignment parameter, then according to the demand capacity in the described Memory Allocation request should the free time the second class internal memory that has distributed cut into the second new class internal memory and distribute.
The second class internal memory that distributes from described Installed System Memory is with the form storage of chained list.Exist in the chained list in described second class and sort according to size.
Can be for the second class memory setting that has used has used sign for the second class memory setting of described distribution uses state, also can be not use sign for the untapped second class memory setting.During with the storage of linked list second class internal memory, can use pointer to indicate used or the untapped second class internal memory.
Technical scheme of the present invention also provides a kind of recovery method of internal memory, comprising:
Based on the capacity of the internal memory that uses, described internal memory is recycled to described first kind internal memory or the second class internal memory, and resets the use state of described first kind internal memory or the second class internal memory.
Because described first kind internal memory or the second class internal memory are according to the form storage of use state with chained list, when therefore the internal memory of the free time that uses is recycled to first kind internal memory or the second class internal memory, can be stored in the afterbody storage of the chained list of first kind internal memory or the second class internal memory correspondence.
Fig. 2 to Fig. 4 is the synoptic diagram of the embodiment of the invention, illustrates below in conjunction with Fig. 2 to Fig. 4.
Fig. 2 is the structural representation of the internal memory that provides of the embodiment of the invention.Installed System Memory 10 is a continuous storage space in system, when each program is moved, need be to system's application internal memory with buffer memory or service data, system is according to the data volume of this secondary program buffer memory or operation, to the program storage allocation, and after using, program reclaims.
With reference to figure 2, before system's off-duty, Installed System Memory 10 is complete and continuous storage spaces, and after system's operation, to system's application internal memory, system distributes to program with Installed System Memory 10 and uses program according to the needs that move.First kind internal memory 201 and the second class internal memory 301 all distribute from Installed System Memory 10, after but first kind internal memory 201 and the second class internal memory 301 are used to complete, do not give back Installed System Memory 10, but it is independent outside Installed System Memory 10, first kind internal memory 201 is recycled in the fixed length memory pool 20, the second class internal memory is recycled in the elongated memory pool 30, uses for follow-up program.
This technology is commonly referred to memory pool technique.Internal memory all distributes from Installed System Memory in the memory pool, after but the internal memory in the memory pool uses, do not give back Installed System Memory, but be recycled to memory pool, during next storage allocation, check preferentially whether idle available internal memory is arranged in the memory pool, if exist, then preferentially use the internal memory in the memory pool, if do not exist, from Installed System Memory, redistribute new internal memory again.
Program is divided into two kinds usually to the internal memory of system's application: a kind of is fixed length, just each internal memory to the identical size of system's application; A kind of is elongated, just program not of uniform size to the internal memory of system's application at every turn.
In the present embodiment, routine processes be map datum, comprise coordinate data (being also referred to as point data) in the map datum, road data (being also referred to as the line data), area data (being also referred to as the face data).The inventor finds that in long-term observation and experiment program is when handling coordinate data, and to the internal memory of system's application fixed length, program is when handling road data and area data, and is each to the elongated internal memory of system's application at every turn.In view of the foregoing, the inventor has proposed technical scheme of the present invention.
In the present embodiment, the demand capacity in the Memory Allocation request that comparison system allocation of parameters and program are sent is to the program storage allocation.The preferred span of described system assignment parameter is 256~512 bytes.
The demand capacity of the internal memory of this application of systematic comparison program (being also referred to as the size of internal memory) and system assignment parameter are according to the comparative result storage allocation.
Fig. 3 is the structural representation of the first kind internal memory that provides of the embodiment of the invention, and with reference to figure 3, if the demand capacity of the internal memory of this application is less than the system assignment parameter, then this application of determining program is the internal memory of fixed length.Can retrieve earlier this moment and whether have idle available first kind internal memory in the fixed length memory pool 20, if there is idle available first kind internal memory, then from fixed length memory pool 20, distribute idle available first kind internal memory, if there is not idle available first kind internal memory in the fixed length memory pool 20, then from Installed System Memory 10, distribute first kind internal memory.System can be disposable distributes the big first kind internal memory 201 such as grade of predetermined number from Installed System Memory 10, the first kind internal memory that the grade of this predetermined number is big is stored with the form of chained list (201a, 201b, 201c), and first sign (202a, 202b, 202c) that the described first kind internal memory of expression uses state is set, exist in the described first kind in the chained list and sort with the use state, described first sign can be arranged on last first kind internal memory that has used (also can be arranged on first untapped first kind internal memory).The chained list of storing described first kind internal memory can have a plurality of, and each chained list can arrange one first sign (can adopt pointer when specifically implementing).The capacity of described first kind internal memory upwards aligns definite according to the capacity of the internal memory of this application of program based on predetermined bite.
The preferred span of described predetermined number is 20~40.The preferred value of described predetermined bite is 4 bytes.The predetermined number of each first kind internal memory that distributes can be identical with capacity, also can be different.For example, the predetermined number of the first kind internal memory of this sub-distribution can be 20, the capacity of each first kind internal memory of this sub-distribution can be 4 bytes, and the predetermined number of the first kind internal memory of Fen Peiing can be 40 next time, and the capacity of each first kind internal memory can be 8 bytes.
Fig. 4 is the structural representation of the second class internal memory that provides of the embodiment of the invention, and with reference to figure 4, if the demand capacity of the internal memory of this application is more than or equal to the system assignment parameter, then this application of determining program is elongated internal memory.Can retrieve earlier this moment and whether have the second idle available class internal memory in the elongated memory pool 30, if there is the second idle available class internal memory, then from elongated memory pool 30, distribute the second idle available class internal memory, if there is not the second idle available class internal memory in the elongated memory pool 30, then from Installed System Memory 10, distribute first kind internal memory.
When from elongated memory pool 30, distributing the second idle available class internal memory, if the difference of the capacity of the second class internal memory that the demand capacity in the Memory Allocation request and this free time are available is greater than described system assignment parameter, then should cut into the second new class internal memory and distribution by the second available class internal memory of free time according to the demand capacity in the described Memory Allocation request, and the second new class memory setting after the cutting will be used state.
When from Installed System Memory, distributing the second class internal memory, only distribute the second required class internal memory of this operation of being in order.The capacity of the second class internal memory of the each application of program does not normally wait, but also can equate.The second class internal memory in the elongated memory pool 30 is also stored with the form of chained list 301a, and the second sign 302a that the described second class internal memory of expression uses state is set.The described second class internal memory is stored in described chained list 301a according to the use state, and sorts according to size.The second sign 302a can be arranged on last second class internal memory that has used (also can be arranged on first untapped second class internal memory).The chained list of storing the described second class internal memory can have a plurality of, and each chained list can arrange one second sign (can adopt pointer when specifically implementing).
Specifically by way of example, if the system assignment parameter is set to 256 bytes, this applies for the internal memory of 3 bytes program, and 3 bytes are upwards alignd according to predetermined bite (4 byte) obtains 4 bytes (capacity of the first kind internal memory of this sub-distribution).Relatively draw 4 bytes (demand capacity in the Memory Allocation request) less than 256 bytes (system assignment parameter), then can disposable distribution 4 bytes (first kind internal memory) multiply by 20 (predetermined numbers) memory headroom of the Installed System Memory of totally 80 bytes, and the memory headroom of this 80 byte is cut into the first kind internal memory of 20 4 byte-sized.These 20 first kind internal memories are with the storage of the form of chained list 201a, and pointer (the first sign 202a) is set indicates the memory headroom of usefulness or the first kind internal memory of usefulness not.Pointer is indicated in last first kind internal memory of usefulness or first first kind internal memory of usefulness not usually.
Program apply for next time in save as 8 bytes, relatively draw 8 bytes less than 256 bytes, then can disposable distribution 8 bytes multiply by 25 first kind internal memories of the Installed System Memory of totally 200 bytes, and the memory headroom of this 200 byte is cut into the little memory headroom of 25 8 byte-sized.These 25 first kind internal memories are with the storage of the form of new chained list 201b, and pointer (the first sign 202b) is set indicates the first kind internal memory of usefulness or the first kind internal memory of usefulness not.Pointer is indicated in last first kind internal memory of usefulness or first first kind internal memory of usefulness not usually.
Program apply for next time in save as 300 bytes, relatively draw 300 bytes (demand capacity in the Memory Allocation request) greater than 256 bytes (system assignment parameter), then the memory headroom of the Installed System Memory of 300 bytes of system assignment (the second class internal memory).The memory headroom that down-stream is applied for again is 256 bytes, relatively draws 256 bytes and equals 256 bytes, then distributes the memory headroom (the second class internal memory) of the Installed System Memory of 256 bytes.The memory headroom of the memory headroom of previous 300 bytes of distributing and 256 bytes of this sub-distribution is with the form storage of chained list 301a, and (256 bytes of memory spaces are preceding to arrange storage with memory headroom order from small to large, the memory headroom of 300 bytes is in the back), and the use state that pointer (the second sign 302a) indicates the second class internal memory is set.
During program subsequent application internal memory, first kind internal memory or the second class internal memory of the free time that system is complementary based on the demand capacity in the Memory Allocation request retrieval and distribution and described demand capacity in existing first kind internal memory or the second class internal memory, and reset described first sign or second sign.
For example, the internal memory of program application 4 bytes, systematic comparison 4 bytes (demand capacity in the Memory Allocation request) are less than 256 bytes (system assignment parameter), whether retrieval exists idle first kind internal memory in chained list 201a (chained lists of 4 bytes) earlier, if exist then should the free time first kind internal memory (4 byte) distribute to program and use, and upgrade first the sign 202a the position, if do not exist, whether retrieval exists idle first kind internal memory in chained list 201b (chained lists of 8 bytes), if exist then should the free time first kind internal memory (8 byte) distribute to program and use, do not give an example according to aforementioned if do not exist then, redistribute the memory headroom of Installed System Memory.
The internal memory of program application 257 bytes, relatively draw 257 bytes (demand capacity in the Memory Allocation request) greater than 256 bytes (system assignment parameter), is then retrieving the second class internal memory that has the free time in chained list 301a (to distribute first kind internal memory when equaling?), if exist, then distribute the second class internal memory of this free time, and upgrade the second sign 302a, if do not exist, then give an example according to aforementioned, redistribute the memory headroom of Installed System Memory.
The internal memory of program application 600 bytes, systematic comparison 600 bytes (demand capacity in the Memory Allocation request) are greater than 256 bytes (system assignment parameter), there is not the memory headroom that is complementary with it among the chained list 301a, then gives an example according to aforementioned, redistribute the memory headroom of Installed System Memory.
If the capacity of the demand internal memory of program application is greater than described system assignment parameter, and the difference of the capacity of the second class internal memory of described demand capacity and existing free time is greater than described system assignment parameter, then according to described demand capacity the second class internal memory of described existing free time cut into the second new class internal memory and distributes and described second sign is set.
By way of example, program is applied for the internal memory of 257 bytes again, relatively draw 257 bytes greater than 256 bytes, then whether retrieval exists the second idle class internal memory in chained list 301a, the internal memory of 257 bytes of previous application this moment uses, the internal memory free time of 600 bytes of applying for later, because 600 bytes-257 byte=343 bytes>256 bytes, then system is cut into two second new class internal memories with the memory headroom of this 600 byte, be respectively 257 bytes and 343 bytes, and 257 new byte allocation are used to program, deposit the second new class internal memory (257 bytes and 343 bytes) in chained list 301a, and upgrade the second sign 302a.
In map datum, the capacity of first kind internal memory commonly used comprises: 4 bytes, 8 bytes, 12 bytes, 16 bytes etc.What wherein frequency of utilization was the highest is 12 bytes, when therefore distributing first kind internal memory from Installed System Memory, distributes 12 bytes of memory spaces of more predetermined number usually.
When the internal memory that recovery uses, capacity based on this internal memory that uses, described internal memory is recycled to described first kind internal memory or the second class internal memory (fixed length memory pool 20 or elongated memory pool 30), and resets the use state of described first kind internal memory or the second class internal memory.When the internal memory of the free time that uses is recycled to first kind internal memory or the second class internal memory, can be stored in first kind internal memory or the second class internal memory correspondence chained list afterbody storage or insert suitable position in the chained list according to the size of storage space.
Technical scheme of the present invention also provides a kind of Memory Allocation device, and described Memory Allocation device comprises:
Judging unit 1 is in order to the demand capacity in the Memory Allocation request of comparison system allocation of parameters and acquisition;
Allocation units 2 are configured to distribute first kind internal memory, and be the first kind memory setting use state of described distribution when described judging unit 1 judges that described demand capacity is less than or equal to described system assignment parameter; The capacity of described first kind internal memory is preset and is complementary with described demand capacity; During greater than described system assignment parameter, distribute the second class internal memory of described demand capacity in the described demand capacity of described judgment unit judges, and be that the second class memory setting of described distribution uses state.
Described allocation units 2 link to each other with judging unit 1, the storage allocation as a result that described allocation units 2 are judged based on judging unit 1.
Concrete, described allocation units 2 comprise: first kind allocation units 21 are configured to distribute the first kind internal memory that has distributed of this free time when having the idle first kind internal memory that has distributed; Otherwise from Installed System Memory, distribute first kind internal memory.
When from Installed System Memory, distributing first kind internal memory, described first kind allocation units 21 each big first kind internal memories such as grade that from described Installed System Memory, distribute predetermined number; Described Memory Allocation device also comprises: administrative unit 3, and in order to the first kind internal memory of described predetermined number is stored with the form of chained list.
When from Installed System Memory, distributing first kind internal memory, described first kind allocation units 21 with described demand capacity based on predetermined bite upwards alignment determine the capacity of first kind internal memory default and that be complementary with described demand capacity.
Described allocation units 2 comprise the second class allocation units 22, are configured to distribute the second class internal memory that has distributed of this free time when having the idle second class internal memory that has distributed; Otherwise from Installed System Memory, distribute the second class internal memory.
The described second class allocation units 22 comprise:
The comparing unit (not shown) is in order to the capacity of the second class internal memory that has distributed of more described demand capacity and this free time;
The cutter unit (not shown), be configured in the difference of the capacity of the second class internal memory that has distributed of the more described demand capacity of described comparing unit and this free time during greater than described system assignment parameter, the second class internal memory that has distributed that should the free time according to described demand capacity cuts into the second new class internal memory and distributes.
Administrative unit 3 is also stored with the form of chained list in order to the second class internal memory that will distribute from described Installed System Memory.Administrative unit 3 sorts according to size existing in the chained list in described second class.
Technical scheme of the present invention has following advantage at least:
Determine that based on the demand capacity in the Memory Allocation request and system assignment parameter the internal memory of this sub-distribution is the internal memory of fixed length or elongated internal memory.If fixed length, then distribute first kind internal memory; If elongated, then distribute the second class internal memory.With fixed length and the elongated storage allocation that combines, not only satisfied the demand of program, and improved the performance of total system.
Adopt memory pool technique, the internal memory of a plurality of fixed length of disposable distribution with the chained list management, and arranges its use state.For elongated internal memory, the elongated internal memory of distribution is managed with chained list, and its use state also is set.This not only can reduce memory fragmentation, and is beneficial to management.
Before storage allocation, whether there be first kind internal memory or the second class internal memory of the free time that is complementary in the first kind internal memory that retrieval has earlier distributed or the second class internal memory, if existence, the then first kind internal memory of this free time that is complementary of priority allocation or the second class internal memory.This not only reduces the consumption to new internal memory, reduces the distribution number of times to new internal memory, and improves the utilization factor of the internal memory that has distributed.
The internal memory that uses is recycled to first kind internal memory or the second class internal memory according to its capacity, realizes the use repeatedly of internal memory with this.This not only reduces the number of times of Memory Allocation, improves the work efficiency of system, and improves the utilization factor of internal memory, reduces memory fragmentation.
Though the present invention with preferred embodiment openly as above; but it is not to limit the present invention; any those skilled in the art without departing from the spirit and scope of the present invention; can utilize method and the technology contents of above-mentioned announcement that technical solution of the present invention is made possible change and modification; therefore; every content that does not break away from technical solution of the present invention; to any simple modification, equivalent variations and modification that above embodiment does, all belong to the protection domain of technical solution of the present invention according to technical spirit of the present invention.

Claims (17)

1. a memory allocation method is characterized in that, comprising:
Demand capacity in the Memory Allocation request of comparison system allocation of parameters and acquisition;
If described demand capacity is less than or equal to described system assignment parameter, then distributes first kind internal memory, and be the first kind memory setting use state of described distribution; The capacity of described first kind internal memory be preset and be complementary with demand capacity in the described Memory Allocation request;
If described demand capacity greater than described system assignment parameter, is then distributed the second class internal memory of described demand capacity, and the second class memory setting use state for distributing.
2. memory allocation method as claimed in claim 1 is characterized in that, described distribution first kind internal memory comprises:
If have the idle first kind internal memory that has distributed, then distribute the first kind internal memory that has distributed of this free time; Otherwise from Installed System Memory, distribute first kind internal memory.
3. memory allocation method as claimed in claim 2, it is characterized in that, the described first kind internal memory that distributes from Installed System Memory comprises: each big first kind internal memory such as grade that distributes predetermined number from described Installed System Memory, the first kind internal memory of described predetermined number is with the form storage of chained list.
4. memory allocation method as claimed in claim 1 is characterized in that, the second class internal memory of the described demand capacity of described distribution comprises:
If have the idle second class internal memory that has distributed, then distribute the second class internal memory that has distributed of this free time; Otherwise from Installed System Memory, distribute the second class internal memory.
5. memory allocation method as claimed in claim 4, it is characterized in that, the second class internal memory that has distributed of described this free time of distribution comprises: if the difference of the capacity of described demand capacity and the second class internal memory that has distributed of this free time is greater than described system assignment parameter, then according to described demand capacity should the free time the second class internal memory that has distributed cut into the second new class internal memory and distribution.
6. memory allocation method as claimed in claim 4 is characterized in that, the second class internal memory that distributes from described Installed System Memory is with the form storage of chained list.
7. memory allocation method as claimed in claim 6 is characterized in that, exists in the chained list in described second class and sorts according to size.
8. memory allocation method as claimed in claim 1, it is characterized in that, the capacity of described first kind internal memory be default and with comprising that demand capacity in the described Memory Allocation request is complementary: with described demand capacity based on the upwards align capacity of definite first kind internal memory of presetting and being complementary with described demand capacity of predetermined bite.
9. a Memory Allocation device is characterized in that, comprising:
Judging unit is in order to the demand capacity in the Memory Allocation request of comparison system allocation of parameters and acquisition;
Allocation units are configured to distribute first kind internal memory when the described demand capacity of described judgment unit judges is less than or equal to described system assignment parameter, and be the first kind memory setting use state of described distribution; The capacity of described first kind internal memory is preset and is complementary with described demand capacity; During greater than described system assignment parameter, distribute the second class internal memory of described demand capacity in the described demand capacity of described judgment unit judges, and be that the second class memory setting of described distribution uses state.
10. Memory Allocation device as claimed in claim 9 is characterized in that, described allocation units comprise: first kind allocation units are configured to distribute the first kind internal memory that has distributed of this free time when having the idle first kind internal memory that has distributed; Otherwise from Installed System Memory, distribute first kind internal memory.
11. Memory Allocation device as claimed in claim 10 is characterized in that, when distributing first kind internal memory from Installed System Memory, described first kind allocation units distribute the big first kind internal memory such as grade of predetermined number at every turn from described Installed System Memory; Described Memory Allocation device also comprises: administrative unit, and in order to the first kind internal memory of described predetermined number is stored with the form of chained list.
12. Memory Allocation device as claimed in claim 10, it is characterized in that, when from Installed System Memory, distributing first kind internal memory, described first kind allocation units with described demand capacity based on predetermined bite upwards alignment determine the capacity of first kind internal memory default and that be complementary with described demand capacity.
13. Memory Allocation device as claimed in claim 9 is characterized in that, described allocation units comprise the second class allocation units, are configured to distribute the second class internal memory that has distributed of this free time when having the idle second class internal memory that has distributed; Otherwise from Installed System Memory, distribute the second class internal memory.
14. Memory Allocation device as claimed in claim 13 is characterized in that, the described second class allocation units comprise:
Comparing unit is in order to the capacity of the second class internal memory that has distributed of more described demand capacity and this free time;
Cutter unit, be configured in the difference of the capacity of the second class internal memory that has distributed of the more described demand capacity of described comparing unit and this free time during greater than described system assignment parameter, the second class internal memory that has distributed that should the free time according to described demand capacity cuts into the second new class internal memory and distributes.
15. Memory Allocation device as claimed in claim 13 is characterized in that, also comprises, administrative unit is stored with the form of chained list in order to the second class internal memory that will distribute from described Installed System Memory.
16. Memory Allocation device as claimed in claim 15 is characterized in that, described administrative unit sorts according to size existing in the chained list in described second class.
17. the recovery method based on the internal memory of each described memory allocation method distribution of claim 1 to 8 is characterized in that, comprising:
Based on the capacity of the internal memory that uses, described internal memory is recycled to described first kind internal memory or the second class internal memory, and resets the use state of described first kind internal memory or the second class internal memory.
CN2011104467832A 2011-12-27 2011-12-27 Memory allocation method and device, and memory recovery method Pending CN103186469A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2011104467832A CN103186469A (en) 2011-12-27 2011-12-27 Memory allocation method and device, and memory recovery method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2011104467832A CN103186469A (en) 2011-12-27 2011-12-27 Memory allocation method and device, and memory recovery method

Publications (1)

Publication Number Publication Date
CN103186469A true CN103186469A (en) 2013-07-03

Family

ID=48677645

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2011104467832A Pending CN103186469A (en) 2011-12-27 2011-12-27 Memory allocation method and device, and memory recovery method

Country Status (1)

Country Link
CN (1) CN103186469A (en)

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103488576A (en) * 2013-09-18 2014-01-01 珠海金山网络游戏科技有限公司 Method for managing small high-performance memory blocks
CN103927264A (en) * 2014-05-12 2014-07-16 中国航空无线电电子研究所 Method for distributing running memory space of map data of airborne digital map software
CN104182355A (en) * 2014-08-29 2014-12-03 广州华多网络科技有限公司 Method and device for memory allocation
CN104461382A (en) * 2014-11-26 2015-03-25 华为技术有限公司 Internal writing method for file server operating multiple file systems and server
CN105468461A (en) * 2016-01-15 2016-04-06 浪潮(北京)电子信息产业有限公司 Memory partitioning method and system
CN105512091A (en) * 2015-12-03 2016-04-20 青岛海信移动通信技术股份有限公司 Memory allocation method and device
CN107077422A (en) * 2015-02-18 2017-08-18 国际商业机器公司 The reason for determining memory external fragmentation
CN108108307A (en) * 2016-11-24 2018-06-01 中移(杭州)信息技术有限公司 A kind of method for processing resource and terminal
CN104021087B (en) * 2014-06-24 2018-07-17 上海众源网络有限公司 Memory headroom management method and system
CN108804340A (en) * 2018-04-02 2018-11-13 武汉斗鱼网络科技有限公司 Method, storage medium, electronic equipment and the system of Android system data record
CN109379246A (en) * 2018-09-21 2019-02-22 锐捷网络股份有限公司 A kind of detection method and device of memory
CN109669877A (en) * 2018-12-11 2019-04-23 腾讯科技(深圳)有限公司 EMS memory management process, device, terminal and storage medium
CN110489237A (en) * 2019-08-20 2019-11-22 深圳市丰润达科技有限公司 Serial data receiving handling method, device and computer readable storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6877081B2 (en) * 2001-02-13 2005-04-05 International Business Machines Corporation System and method for managing memory compression transparent to an operating system
CN1604051A (en) * 2003-09-30 2005-04-06 三星电子株式会社 Method and apparatus for dynamic memory management within an object-oriented program
CN101122883A (en) * 2006-08-09 2008-02-13 中兴通讯股份有限公司 Memory allocation method for avoiding RAM fragmentation
CN101414281A (en) * 2007-10-19 2009-04-22 大唐移动通信设备有限公司 Internal memory management method and system
CN101968772A (en) * 2010-10-22 2011-02-09 烽火通信科技股份有限公司 Method for implementing efficient memory pool of embedded system
CN102156675A (en) * 2010-02-12 2011-08-17 中兴通讯股份有限公司 Method and device for allocating memory

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6877081B2 (en) * 2001-02-13 2005-04-05 International Business Machines Corporation System and method for managing memory compression transparent to an operating system
CN1604051A (en) * 2003-09-30 2005-04-06 三星电子株式会社 Method and apparatus for dynamic memory management within an object-oriented program
CN101122883A (en) * 2006-08-09 2008-02-13 中兴通讯股份有限公司 Memory allocation method for avoiding RAM fragmentation
CN101414281A (en) * 2007-10-19 2009-04-22 大唐移动通信设备有限公司 Internal memory management method and system
CN102156675A (en) * 2010-02-12 2011-08-17 中兴通讯股份有限公司 Method and device for allocating memory
CN101968772A (en) * 2010-10-22 2011-02-09 烽火通信科技股份有限公司 Method for implementing efficient memory pool of embedded system

Cited By (21)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103488576A (en) * 2013-09-18 2014-01-01 珠海金山网络游戏科技有限公司 Method for managing small high-performance memory blocks
CN103488576B (en) * 2013-09-18 2016-09-07 珠海金山网络游戏科技有限公司 A kind of high-performance block of cells EMS memory management process
CN103927264A (en) * 2014-05-12 2014-07-16 中国航空无线电电子研究所 Method for distributing running memory space of map data of airborne digital map software
CN103927264B (en) * 2014-05-12 2016-08-24 中国航空无线电电子研究所 A kind of distribution method in airborne digital map software map datum running memory space
CN104021087B (en) * 2014-06-24 2018-07-17 上海众源网络有限公司 Memory headroom management method and system
CN104182355A (en) * 2014-08-29 2014-12-03 广州华多网络科技有限公司 Method and device for memory allocation
CN104182355B (en) * 2014-08-29 2017-06-23 广州华多网络科技有限公司 A kind of memory allocation method and device
CN104461382B (en) * 2014-11-26 2018-06-19 华为技术有限公司 Run the inside write method and server of the file server of multiple file system
CN104461382A (en) * 2014-11-26 2015-03-25 华为技术有限公司 Internal writing method for file server operating multiple file systems and server
CN107077422B (en) * 2015-02-18 2020-05-12 国际商业机器公司 Determining causes of memory external fragmentation
CN107077422A (en) * 2015-02-18 2017-08-18 国际商业机器公司 The reason for determining memory external fragmentation
CN105512091B (en) * 2015-12-03 2019-03-12 青岛海信移动通信技术股份有限公司 A kind of memory allocation method and device
CN105512091A (en) * 2015-12-03 2016-04-20 青岛海信移动通信技术股份有限公司 Memory allocation method and device
CN105468461A (en) * 2016-01-15 2016-04-06 浪潮(北京)电子信息产业有限公司 Memory partitioning method and system
CN108108307A (en) * 2016-11-24 2018-06-01 中移(杭州)信息技术有限公司 A kind of method for processing resource and terminal
CN108804340A (en) * 2018-04-02 2018-11-13 武汉斗鱼网络科技有限公司 Method, storage medium, electronic equipment and the system of Android system data record
CN108804340B (en) * 2018-04-02 2020-09-04 武汉斗鱼网络科技有限公司 Android system data recovery method, storage medium, electronic device and system
CN109379246A (en) * 2018-09-21 2019-02-22 锐捷网络股份有限公司 A kind of detection method and device of memory
CN109379246B (en) * 2018-09-21 2021-03-05 锐捷网络股份有限公司 Memory detection method and device
CN109669877A (en) * 2018-12-11 2019-04-23 腾讯科技(深圳)有限公司 EMS memory management process, device, terminal and storage medium
CN110489237A (en) * 2019-08-20 2019-11-22 深圳市丰润达科技有限公司 Serial data receiving handling method, device and computer readable storage medium

Similar Documents

Publication Publication Date Title
CN103186469A (en) Memory allocation method and device, and memory recovery method
US9003135B2 (en) Efficient allocation and reclamation of thin-provisioned storage
CN103020174B (en) Similarity analysis method, Apparatus and system
CN102004675A (en) Cross-process data transmission method, device and network equipment
US6757802B2 (en) Method for memory heap and buddy system management for service aware networks
KR101502896B1 (en) Distributed memory cluster control apparatus and method using map reduce
EP3504628B1 (en) Memory management method and device
CN101847127B (en) Memory management method and device
CN104731799B (en) Main memory DBM device
CN103678160B (en) A kind of method and apparatus of data storage
CN101944124A (en) Distributed file system management method, device and corresponding file system
CN103412884B (en) The management method of embedded database under a kind of isomery storage medium
US20090006502A1 (en) Application-Specific Heap Management
CN101488919B (en) Memory address allocation method and apparatus
CN102591789A (en) Storage space recovery method and storage space recovery device
CN107844372B (en) Memory allocation method and system
CN101777061A (en) JAVA card object management method and JAVA card
US6219772B1 (en) Method for efficient memory allocation of small data blocks
CN105874426B (en) A kind of batch processing method and device of system call command
CN101344861A (en) Smart card internal memory management method
CN1679005A (en) Dynamic memory management
CN103617123A (en) Method and system for memory management by memory block
CN104850505A (en) Memory management method and system based on chain type stacking
CN103246549A (en) Method and system for data transfer
CN102945275A (en) File defragmentation method, file defragmentation unit and file defragmentation device

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: 20130703

RJ01 Rejection of invention patent application after publication