CN110209493A - EMS memory management process, device, electronic equipment and storage medium - Google Patents
EMS memory management process, device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN110209493A CN110209493A CN201910290004.0A CN201910290004A CN110209493A CN 110209493 A CN110209493 A CN 110209493A CN 201910290004 A CN201910290004 A CN 201910290004A CN 110209493 A CN110209493 A CN 110209493A
- Authority
- CN
- China
- Prior art keywords
- memory
- queue
- index
- circulation
- circulation queue
- 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
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
- G06F9/5016—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The embodiment of the present application provides a kind of EMS memory management process, device, electronic equipment and storage medium.This method comprises: determining first circulation queue according to the capacity requirement of first object object;When, there are when free memory index, the target memory in first position indicated by the front pointer from first circulation queue in reading free memory index indexes, and updates first position indicated by front pointer in first circulation queue;Target memory is indexed corresponding memory source to distribute to first object object.Technical solution provided by the embodiments of the present application, time needed for Memory Allocation that is to say the time for reading the index of the free memory in position indicated by front pointer, it is not related with used memory size, the time complexity of technical solution i.e. provided by the embodiments of the present application is O [1], and the efficiency of Memory Allocation can be improved.
Description
Technical field
The invention relates to technical field of memory, in particular to a kind of EMS memory management process, device, electronic equipment and
Storage medium.
Background technique
Currently, electronic equipment typically sets up perfect memory management mechanism so that process in operating status or
Thread can be assigned to enough memory headrooms, and process out of service or thread being capable of timely releasing memory spaces.
In the related technology, the process of storage allocation is specific as follows: when a certain process or thread application memory headroom distribute,
Memory management module successively traverses memory block, if the memory block is occupied or the memory block and above-mentioned process or thread application
When memory size mismatches, then continue to traverse next memory block, not occupied by other processes or thread until traversing, and accord with
When closing the memory block of the memory size demand of the process of stating or thread, it is empty that the memory block traversed is distributed into above-mentioned application memory
Between the process distributed or thread.
In the related art, EMS memory occupation amount is bigger, then memory management process traverses the memory block for meeting distributive condition
The required time is longer, and allocative efficiency is more low.
Summary of the invention
The embodiment of the present application provides a kind of EMS memory management process, device, terminal and storage medium, can be used for solving correlation
Time needed for memory management process traverses the memory block for meeting distributive condition in technology is longer, and allocative efficiency is more low
Problem.
On the one hand, the embodiment of the present application provides a kind of EMS memory management process, which comprises
First circulation queue is determined according to the capacity requirement of first object object;Wherein, the capacity requirement is used to indicate
First memory size needed for the first object object, the first circulation queue is for storing free memory index;
When being indexed in the first circulation queue there are the free memory, refer to from the head of the queue of the first circulation queue
The target memory index in the free memory index is read in first position indicated by needle, and updates the front pointer institute
The first position of instruction;
The target memory is indexed corresponding memory source to distribute to the first object object.
On the other hand, the embodiment of the present application provides a kind of memory management device, and described device includes:
First determining module, for determining first circulation queue according to the capacity requirement of first object object;Wherein, described
First memory size needed for capacity requirement is used to indicate the first object object, the first circulation queue can for storing
It is indexed with memory;
Index obtains module, for when indexing in the first circulation queue there are the free memory, from described the
The target memory index in the free memory index is read in first position indicated by the front pointer of one round-robin queue;
Location updating module, for updating first position indicated by the front pointer;
Memory allocating module is distributed for the target memory to be indexed corresponding memory source to the first object pair
As.
Another aspect, the embodiment of the present application provide a kind of electronic equipment, and the electronic equipment includes processor and storage
Device is stored at least one instruction, at least a Duan Chengxu, code set or instruction set in the memory, and described at least one refers to
It enables, an at least Duan Chengxu, the code set or instruction set are loaded by the processor and executed to realize above-mentioned memory pipe
Reason method.
Another aspect, the embodiment of the present application provide a kind of computer readable storage medium, the computer-readable storage
Be stored at least one instruction, at least a Duan Chengxu, code set or instruction set in medium, at least one instruction, it is described extremely
A few Duan Chengxu, the code set or instruction set are loaded by processor and are executed to realize above-mentioned EMS memory management process.
Another aspect provides a kind of computer program product, when the computer program product is performed, is used to hold
The above-mentioned EMS memory management process of row.
Technical solution provided by the embodiments of the present application can be brought the following benefits:
All free memory resources are managed by using round-robin queue, when a certain process or thread need to apply
When memory headroom, as long as after determining the round-robin queue to match with the memory size of application, from the head of the queue of above-mentioned round-robin queue
Free memory index is directly read in pointer, can be obtained above-mentioned free memory later and be indexed corresponding memory headroom, compared to
The memory headroom for meeting the use demand of above-mentioned process or thread, this Shen are found by way of traversing memory block in the related technology
Please the technical solution that provides of embodiment, the time needed for Memory Allocation that is to say read in position indicated by front pointer can
The time indexed with memory, and used memory size is not related namely technical solution provided by the embodiments of the present application
Time complexity is O [1], and the efficiency of Memory Allocation can be improved.
Detailed description of the invention
Fig. 1 is the interface schematic diagram for the application scenarios that the application one embodiment provides;
Fig. 2 is the flow chart for the EMS memory management process that the application one embodiment provides;
Fig. 3 is the schematic diagram of the round-robin queue after the initialization that the application one embodiment provides;
Fig. 4 is the flow chart for the memory allocation method that the application one embodiment provides;
Fig. 5 is the schematic diagram for the Memory Allocation that the application one embodiment provides;
Fig. 6 is the flow chart for the EMS memory management process that another embodiment of the application provides;
Fig. 7 is the flow chart for the memory release method that another embodiment of the application provides;
Fig. 8 is the schematic diagram for the memory release that another embodiment of the application provides;
Fig. 9 is the histogram for the memory usage that the relevant technologies provide;
Figure 10 is the histogram for the memory usage that the application one embodiment provides;
Figure 11 is the block diagram for the memory management device that the application one embodiment provides;
Figure 12 is the block diagram for the memory management device that the application one embodiment provides;
Figure 13 is the block diagram for the electronic equipment that the application one embodiment provides.
Specific embodiment
To keep the purposes, technical schemes and advantages of the application clearer, below in conjunction with attached drawing to the application embodiment party
Formula is described in further detail.
Technical solution provided by the embodiments of the present application carries out pipe to all free memory resources by using round-robin queue
Reason, when a certain process or thread need to apply memory headroom, as long as determining the circulation to match with the memory size of application
After queue, free memory index is directly read from the front pointer of above-mentioned round-robin queue, can be obtained later above-mentioned available interior
The corresponding memory headroom of index is deposited, meets above-mentioned process or line compared to finding by way of traversing memory block in the related technology
The memory headroom of the use demand of journey, technical solution provided by the embodiments of the present application, time needed for Memory Allocation that is to say reading
The time (namely head of the queue distribution) for taking the free memory in position indicated by front pointer to index, with used memory size
Not related, i.e., the time complexity of technical solution provided by the embodiments of the present application is O [1], and the effect of Memory Allocation can be improved
Rate.
A kind of EMS memory management process is also provided in the related technology, memory management module gives each process storage allocation space,
Each process individually manages the memory headroom being assigned to, and is isolated each other.When the memory usage of some process is lower,
Remaining memory source can not be shared to the use of other processes, cause the overall utilization rate of memory relatively low.
Technical solution provided by the embodiments of the present application is managed all free memory resources by round-robin queue, and
Each process or thread can access round-robin queue according to the capacity of itself to apply for memory headroom, compared to the relevant technologies
In each process individually manage oneself memory headroom, technical solution provided by the embodiments of the present application can reduce memory fragmentation,
Increase the overall utilization rate of memory.
The executing subject of technical solution provided by the embodiments of the present application, each step can be electronic equipment.The electronic equipment
The terminal device that can be such as smart phone, tablet computer, laptop or desktop computer etc is also possible to service
Device, the embodiment of the present application are not construed as limiting this.Optionally, electronic equipment includes memory management module, the executing subject of each step
It is also possible to the memory management module.
Technical solution provided by the embodiments of the present application can be applied there are under the application scenarios of multi-process high concurrent.
Illustratively, above-mentioned multi-process, high concurrent application scenarios can be the field being managed to the group in social application program
Scape.User needs constantly to carry out memory point during creating group, dismissing group, addition group members, delete group members
Match and memory discharges, completes above-mentioned Memory Allocation/release process using technical solution provided by the embodiments of the present application at this time.
In conjunction with reference Fig. 1, it illustrates the interface schematic diagrams of group provided by the embodiments of the present application.When user is in group
Any one module operation when, memory management module completes Memory Allocation using technical solution provided by the embodiments of the present application
And release process.
Referring to FIG. 2, the flow chart of the EMS memory management process provided it illustrates the application one embodiment, method include
The following steps (step 201~step 203).
Step 201, first circulation queue is determined according to the capacity requirement of first object object.
First object object can be that there are the process of Memory Allocation demand or threads.In a kind of possible implementation
In, when a certain process or thread have just started starting operation, there are Memory Allocation demands for the process or thread.Alternatively possible
Implementation in, when a certain process or the memory size deficiency of thread, there are Memory Allocation demands for the process or thread.Hold
Amount demand is used to indicate the first memory size needed for first object object.First memory size can be according to the first object pair
Operation duration, operation conditions, operation result of elephant etc. actually determine that the embodiment of the present application is not construed as limiting this.Illustratively,
First memory size needed for one target object is 212kb.
First circulation queue is for storing free memory index, the quantity of the free memory index of first circulation queue storage
Value be 0 arrive first circulation queue queue length.In the embodiment of the present application, when can be used for first circulation queue storage is interior
When depositing the quantity of index greater than 0, memory management module can continue to execute subsequent Memory Allocation process.
When the capacity of the free memory index of first circulation queue storage is not 0, each free memory index is right respectively
The memory size for the memory block answered can be identical, can not also be identical, in the embodiment of the present application, only with each free memory index
It is illustrated for the memory size of corresponding memory block is identical, by the above-mentioned means, one side memory management module can be only
The only corresponding memory size of record round-robin queue indexes corresponding memory appearance without recording each free memory in round-robin queue
Amount, it is possible to reduce EMS memory occupation, another aspect object only needs to search round-robin queue according to the memory size needed for itself, and nothing
The position that the corresponding free memory index of memory size needed for itself need to be searched, improves Memory Allocation efficiency.
Optionally, step 201 can be implemented as following two sub-steps:
Step 201a obtains the corresponding relationship between different round-robin queues and different memory sizes.
The corresponding memory size of round-robin queue is used to indicate the free memory stored in round-robin queue and indexes corresponding memory
The memory size of block.In the embodiment of the present application, memory headroom can be divided into difference by memory management module according to demand
The memory block of capacity is deposited, it, can be in conjunction with the interior of the memory headroom needed for itself when subsequent a certain business needs to apply memory headroom
Capacity is deposited to apply for suitable memory block, so that memory benefit can be improved as much as possible under the premise of meeting business demand
With rate.Illustratively, the corresponding relationship between round-robin queue and memory size can be with reference table -1.
Table -1
Round-robin queue | Memory size |
Round-robin queue 1 | 1kb |
Round-robin queue 2 | 2kb |
Round-robin queue 3 | 8kb |
Round-robin queue 4 | 256kb |
By taking round-robin queue 3 as an example, the free memory stored in the round-robin queue 3 indexes the memory size of corresponding memory block
For 8kb.
Optionally, all it is stored with above-mentioned corresponding relationship in the head information of first object object, first object object can be from
Above-mentioned corresponding relationship is directly acquired in head information.
The round-robin queue that memory size is target memory capacity is determined as first circulation queue by step 201b.
Target memory capacity refers to that the difference greater than the first memory size, and between the first memory size meets default item
The memory size of part.Above-mentioned preset condition is also possible to the minimum of the difference between target memory capacity and the first memory size.It is logical
Cross aforesaid way, can make the application of first object object to the memory size of memory block meeting making for first object object
Under the premise of with demand, memory headroom is saved, as much as possible to improve the utilization rate of memory block.
In conjunction with above-mentioned table -1, the first memory size needed for first object object is 6kb, and memory management module determines mesh
Mark memory size is 8kb, and round-robin queue 3 is determined as first circulation queue later.
In other possible implementations, above-mentioned preset condition can be target memory capacity and the first memory size it
Between difference be less than preset threshold, preset threshold can according to experiment or experience set.
Optionally, before step 201, memory management module also needs to detect whether first object object obtains with memory
Weighting limit.Memory obtains permission and refers to the front pointer position by accessing first circulation queue to obtain free memory index
Permission.
Optionally, memory management module determines whether first object object there is memory to obtain permission by resource lock.
If first object object acquisition is to resource lock, the first object object is with resource acquisition permission;If first object object is not
Resource lock is got, then the first object object does not have resource acquisition permission.It needs to illustrate to be, memory management module can be with
The acquisition sequence of resource lock is determined according to the execution priority of object, the high object of priority can preferentially obtain resource lock,
After the high object of above-mentioned priority is successfully applied to memory headroom, resource lock can be discharged, other objects can obtain at this time
Get resource lock.Used resource lock is semaphore in the embodiment of the present application.
When memory management module detects that first object object has memory access right, subsequent step is continued to execute
101, when memory management module detects that first object object does not have memory acquisition permission, do not execute subsequent step.Pass through
Aforesaid way, when can access first circulation queue simultaneously to avoid multithreading caused by collision problem so that the memory management
Mechanism being capable of orderly, health operation.
Step 202, it is read in first position indicated by the front pointer from first circulation queue in free memory index
Target memory index, and update first position indicated by front pointer.
First position indicated by the front pointer of first circulation queue is first object object in access first circulation team
The access position of column.First position indicated by front pointer can be any position in first circulation queue.It follows when first
After initialization is completed in ring queue, first position indicated by front pointer that is to say first position in first circulation queue.
In conjunction with reference Fig. 3, it illustrates the signals of the first circulation queue after the initialization shown in one exemplary embodiment of the application
Figure.The queue length of first circulation queue is N, in first circulation queue after initialization, position indicated by front pointer
It that is to say first position in first circulation queue.
After the first position indicated by the front pointer is by a certain process or thread accesses, indicated by the front pointer
First position can be updated according to the sequence of positions in first circulation queue.Illustratively, indicated by the front pointer
When one position is the 2nd position in first circulation queue, the first position is by a certain object accesses mistake at this time, then Head-of-line
Indicated first position is the 3rd position in first circulation queue.It should be noted that working as head of the queue in round-robin queue
When first position indicated by pointer is the last one position in round-robin queue, if the first position is by a certain object accesses
It crosses, then first position indicated by front pointer is updated to first position in round-robin queue.
In the embodiment of the present application, be stored in first position indicated by the front pointer of first circulation queue it is above-mentioned can
With memory index in one, when a certain object accesses first position, it can read free memory index, the reading
To free memory index that is to say target memory index.
In addition, first position indicated by front pointer needs after the free memory index in first position is read
Adaptability updates, so that storing other free memory indexes, subsequent other objects in the first position of front pointer institute pointer
When accessing first circulation queue, free memory index can be also read directly from first position indicated by front pointer, with
The memory management mechanism orderly, is healthily run.
Optionally, the queue length of first circulation queue is n (n is the integer greater than 1).It is signified that front pointer is updated at this time
The first position shown can implement are as follows: when first position, corresponding first position number is less than n, first position is numbered
Add 1, obtains the corresponding first position number in updated first position;When first position, number is equal to n, first position is compiled
Number it is updated to 1, first position indicated by front pointer is first by the last one location updating in round-robin queue at this time
Position.
Optionally, the free memory index stored in first circulation queue can be dispensed gradually.When more object application
Free memory index, and releasing memory space object it is less when, the free memory index that stores in first circulation queue can be by
It is decrescence small, until being 0.Therefore, free memory is read in the first position indicated by the front pointer from first circulation queue
Before target memory index in index, memory management module needs first to detect the free memory rope stored in first circulation queue
Whether the quantity drawn is greater than zero.
Optionally, memory management module numbers the size relation between the number of the second position according to first position, calculates
The quantity of the free memory index stored in first circulation queue.
First position number is the corresponding Position Number in first position.Second position number is the team in first circulation queue
The corresponding Position Number in the second position indicated by tail pointer.
The second position indicated by the rear pointer of first circulation queue is first object object in access first circulation team
Last access position when column.The second position indicated by rear pointer can be any position in first circulation queue.When
After initialization is completed in first circulation queue, the second position indicated by front pointer that is to say last in first circulation queue
A position.In conjunction with reference Fig. 3, it illustrates the first circulation queues after the initialization shown in one exemplary embodiment of the application
Schematic diagram.The queue length of first circulation queue is N, in first circulation queue after initialization, indicated by rear pointer
Position that is to say the last one position in first circulation queue.
When certain an object releasing memory, and when the memory size of the release and first circulation queue match, the tail of the queue
The second position indicated by pointer can be updated according to the sequence of positions in first circulation queue.Illustratively, when tail of the queue refers to
When the second position indicated by needle is the 2nd position in first circulation queue, certain an object releasing memory, discharges at this time
Memory size memory size corresponding with first circulation queue is identical, then the second position indicated by rear pointer is first circulation
The 3rd position in queue.It should be noted that in round-robin queue, the second position indicated by the rear pointer is circulation
When the last one position in queue, certain an object releasing memory at this time, the memory size and first circulation queue pair of release
The memory size answered is identical, then the second position indicated by rear pointer is updated to first position in round-robin queue.
Optionally, when the second position, number is greater than first position number, second position number is numbered with first position
Between difference, be determined as the free memory stored in first circulation queue index quantity.Illustratively, first position is numbered
It is 1, second position number is m (namely queue length of first circulation queue), and what is stored in first circulation queue at this time is available
The quantity of memory index is m-1.
When number is less than first position number when the second position, the queue length of first circulation queue is subtracted into first position
Second position number is numbered and added, the quantity of the free memory stored in first circulation queue index is obtained.
When the quantity of the free memory index stored in first circulation queue is greater than zero, execute from first circulation queue
The step of target memory index in n free memory index is read in first position indicated by front pointer.It follows when first
When the quantity of the free memory index stored in ring queue is equal to zero, terminal needs to redefine round-robin queue at this time, and from new
Free memory index is read in position indicated by the front pointer of the round-robin queue determined.
Step 203, target memory corresponding memory source is indexed to distribute to first object object.
Optionally, memory management module is after getting free memory index, in included by free memory index
The information such as counterfoil number, memory block position are back to first object object, and memory management module is divided to first object object at this time
With memory success.
In conjunction with reference Fig. 4, it illustrates the flow charts for the Memory Allocation that the application one embodiment provides.Detection needs first
Want whether the process of Memory Allocation gets resource lock, if the process successfully gets resource lock, detecting in round-robin queue is
No there are free memory indexes, and if it exists, then reads free memory index from position indicated by front pointer, and is returned
It is back to above-mentioned process, moves front pointer later, to be updated to position indicated by front pointer;If it does not exist, then it ties
Line journey.In addition, being continued to obtain resource lock by the process, until successfully obtaining if above-mentioned process fails to get resource lock
To resource lock.
In conjunction with reference Fig. 5, it illustrates the schematic diagrames of Memory Allocation provided by the embodiments of the present application.Indicated by front pointer
Initial position be 1, process 1 applies for Memory Allocation after getting resource lock, and memory management module will store in position 1 later
Free memory index 1 distribute to process 1, move front pointer later, be 2 by location updating indicated by front pointer.
In conclusion technical solution provided by the embodiments of the present application, comes by using round-robin queue to all free memories
Resource is managed, when a certain process or thread need to apply memory headroom, as long as determining the memory size phase with application
After matched round-robin queue, free memory index is directly read from the front pointer of above-mentioned round-robin queue, can be obtained later
Above-mentioned free memory indexes corresponding memory headroom, meets compared to being found by way of traversing memory block in the related technology
State the memory headroom of the use demand of process or thread, technical solution provided by the embodiments of the present application, when needed for Memory Allocation
Between that is to say the time for reading the index of the free memory indicated by front pointer in position, do not have with used memory size
The time complexity of relationship namely technical solution provided by the embodiments of the present application is O [1], and the efficiency of Memory Allocation can be improved.
In addition, all free memory resources are managed by round-robin queue, and each process or thread can roots
Round-robin queue is accessed according to the capacity of itself to apply for memory headroom, individually manages oneself compared to each process in the related technology
Memory headroom, technical solution provided by the embodiments of the present application can reduce memory fragmentation, increase the overall utilization rate of memory.
The process of memory release is explained below.In the alternative embodiment provided based on embodiment illustrated in fig. 1
In, which further includes following steps:
Step 601, second circulation queue is determined according to the release capacity of the second target object.
Second target object refers to that there are the processes or thread of memory release demand.In one possible implementation,
When a certain process or thread terminate operation, there are memories to discharge demand for the process or thread.In alternatively possible realization side
It, can be empty by the memory of earlier application when the bigger memory headroom of memory size is arrived in the application of a certain process or thread in formula
Between discharge, there are memories to discharge demand for the process or thread at this time.Release capacity is used to indicate the release of the second target object
Memory size.Discharging capacity can actually determine according to memory size of the occupied memory headroom of the second target object etc.,
The embodiment of the present application is not construed as limiting this.Illustratively, the release capacity of the second target object is 256kb.
Second circulation queue is for storing free memory index.The number for the free memory index that second circulation queue is stored
The value of amount is 0 queue length for arriving second circulation queue.In the embodiment of the present application, can be used when second circulation queue storage
When the quantity of memory index is less than the length of second circulation queue, memory management module can continue to execute subsequent memory release
Process.
Optionally, step 601 can implement are as follows: determine the round-robin queue that corresponding memory size is release capacity
For second circulation queue.By taking table -1 as an example, the release capacity of the second target object is 256kb, then memory management module will recycle
Queue 4 is determined as second circulation queue.
Optionally, before step 601, memory management module also needs to detect whether the second target object is released with memory
It delegates power limit.It is releasing memory that memory, which discharges permission, and updated second circulation queue is written in the memory of releasing memory index
Rear pointer position permission.
Optionally, memory management module determines whether the second target object has memory release power by resource lock mode
Limit.If the second semantic object extraction is to resource lock, 21 target object is with memory release permission;If the second target object
Resource lock has not been obtained, then second target object does not have memory release permission.It needs to illustrate to be, memory management module can
To determine the acquisition sequence of resource lock according to the execution priority of object, the high object of priority can preferentially obtain resource
Lock can discharge resource lock after the high object of above-mentioned priority is successfully applied to memory headroom, and other objects can be at this time
Get resource lock.
When memory management module detects that the second target object has memory release permission, subsequent step is continued to execute
601, when memory management module detects that the second target object does not have memory release permission, do not execute subsequent step.Pass through
Aforesaid way, can to avoid multithreading at the same time releasing memory when caused by collision problem so that the memory management mechanism energy
Enough operations orderly, healthy.
Step 602, position indicated by the rear pointer of second circulation queue, and second circulation team in the updated are updated
The corresponding memory index of memory source to be released is stored in position indicated by the rear pointer of column.
Optionally, the length of second circulation queue is m, indicated by the rear pointer of the second circulation queue before update
When Position Number is m, then Position Number indicated by the rear pointer of second circulation queue is updated to 1;Before update
It, then will be indicated by the rear pointer of second circulation queue when Position Number indicated by the rear pointer of two round-robin queues is less than m
Position Number be updated to m+1.
Step 603, memory source to be released is discharged.
The embodiment of the present application is not construed as limiting the execution sequence of step 602 and step 603.Memory management module can first be held
Row step 602, then execute step 603;Step 603 can also be first carried out, then executes step 602;It may also be performed simultaneously step
602 and step 603.
In conjunction with reference Fig. 7, it illustrates the flow charts for the memory release that the application one embodiment provides.Detection needs first
Whether the process for wanting memory to discharge gets resource lock, if the process successfully gets resource lock, whether detects rear pointer
It is legal, if legal, then rear pointer is moved, to update position indicated by rear pointer, rear pointer in the updated later
The corresponding memory index of memory source to be released is stored in indicated position.In addition, if above-mentioned process fails to get money
Source lock is then continued to obtain resource lock by the process, until successfully getting resource lock.
In conjunction with reference Fig. 8, it illustrates the schematic diagrames of Memory Allocation provided by the embodiments of the present application.Second circulation queue
Queue length is N, and initial position indicated by rear pointer is N, and process 3 applies for that memory discharges after getting resource lock, it
Location updating indicated by rear pointer is 1, stored in position 1 later by the mobile rear pointer of memory management module afterwards
The corresponding memory index (namely memory block 3) of memory source to be released.
In conclusion technical solution provided by the embodiments of the present application, comes by using round-robin queue to all free memories
Resource is managed, when a certain process or thread need releasing memory space, as long as determining the memory size phase with release
After matched round-robin queue, updates position indicated by rear pointer and store the corresponding memory index of the memory of release to more
Position indicated by rear pointer after new, technical solution provided by the embodiments of the present application, the time needed for memory release namely
It is that memory index is stored to time needed for position indicated by updated rear pointer, i.e., skill provided by the embodiments of the present application
The time complexity of art scheme is O [1], and the efficiency of Memory recycle can be improved.
In conjunction with reference Fig. 9, it illustrates the histograms for the memory usage that the relevant technologies provide.Fig. 9 shows group's pipe
It manages under scene, manages the memory usage and the asynchronous memory usage of number of members of the process of group basis information.Knot
It closes and refers to Figure 10, it illustrates the histograms for the memory usage that the application one embodiment provides.Figure 10 shows group's pipe
It manages under scene, manages the memory usage and the asynchronous memory usage of number of members of the process of group basis information.
Comparison diagram 9 and Figure 10 are available, technical solution provided by the embodiments of the present application, provide compared to the relevant technologies
Memory Management can be improved memory usage, reduce memory fragmentation.
Following is the application Installation practice, can be used for executing the application embodiment of the method.It is real for the application device
Undisclosed details in example is applied, the application embodiment of the method is please referred to.
Figure 11 is please referred to, it illustrates the block diagrams for the memory management device that the application one embodiment provides.Device tool
There is the function of realizing the above method, the function can also be executed corresponding software realization by hardware realization by hardware.It should
Device may include:
First determining module 1101, for determining first circulation queue according to the capacity requirement of first object object;Wherein,
First memory size needed for the capacity requirement is used to indicate the first object object, the first circulation queue is for depositing
Store up free memory index.
Index obtain module 1102, for when in the first circulation queue there are the free memory index when, from institute
State the target memory rope read in the free memory index in first position indicated by the front pointer of first circulation queue
Draw.
Location updating module 1103, for updating first position indicated by the front pointer.
Memory allocating module 1104 is distributed for the target memory to be indexed corresponding memory source to first mesh
Mark object.
In the alternative embodiment provided based on embodiment illustrated in fig. 11, Figure 12, described device are please referred to further include:
Computing module 1105, for calculating institute according to the size relation between first position number and second position number
The quantity of the free memory index stored in first circulation queue is stated, the first position number is the first position pair
The Position Number answered, second position number are the second positions pair indicated by rear pointer in the first circulation queue
The Position Number answered.
The index obtains module 1102, for when the free memory index stored in the first circulation queue
When quantity is greater than zero, executing can be in described in reading in first position indicated by the front pointer from the first circulation queue
The step of depositing the target memory index in index.
Optionally, the computing module 1105, is used for:
When the second position, number is greater than the first position number, by second position number and described first
Difference between Position Number is determined as the quantity of the free memory stored in the first circulation queue index;
When the second position, number is less than the first position number, by the queue length of the first circulation queue
Subtract the first position and number and add second position number, obtain storing in the first circulation queue it is described can
The quantity indexed with memory.
In the alternative embodiment provided based on embodiment illustrated in fig. 11, the queue determining module 1101 is used for:
Obtain the corresponding relationship between different round-robin queues and different memory sizes, the corresponding memory of the round-robin queue holds
Amount, is used to indicate the memory size that the free memory stored in the round-robin queue indexes corresponding memory block;
The round-robin queue that memory size is target memory capacity is determined as the first circulation queue, the target memory
Capacity refers to that the difference greater than first memory size, and between first memory size meets the memory of preset condition
Capacity.
In the alternative embodiment provided based on embodiment illustrated in fig. 11, Figure 12, described device are please referred to further include:
Permission detection module 1106.
Permission detection module 1106, for detecting whether the first object object there is memory to obtain permission.
The queue determining module 1101 is also used to if it is detected that there is the first object object memory to obtain power
Limit, then execute the step of capacity requirement according to the first object object determines the first circulation queue.
In the alternative embodiment provided based on embodiment illustrated in fig. 11, the queue length of the first circulation queue
For n, the location updating module 1103 is used for:
When the first position, corresponding first position number is less than the n, first position number plus 1 obtain
It is numbered to the corresponding first position in the updated first position;
When number is equal to the n when the first position, first position number is updated to 1.
In the alternative embodiment provided based on embodiment illustrated in fig. 11, Figure 12, described device are please referred to further include:
Second determining module 1107, for determining second circulation queue according to the release capacity of the second target object;Wherein,
The release capacity is used to indicate the second memory size of the second target object release, and the second circulation queue is for depositing
Store up free memory index.
The location updating module 1108, for updating position indicated by the rear pointer of the second circulation queue.
Index memory module 1108, position indicated by the rear pointer for the second circulation queue in the updated
The corresponding memory index of middle storage memory source to be released.
Memory release module 1109, for discharging the memory source to be released.
Figure 13 shows the structural block diagram of the electronic equipment 1300 of one exemplary embodiment of the application offer.The electronics is set
Standby 1300 may is that smart phone, tablet computer, MP3 player (Moving Picture Experts Group Audio
Layer III, dynamic image expert's compression standard audio level 3), MP4 (Moving Picture Experts Group
Audio Layer IV, dynamic image expert's compression standard audio level 4) player, laptop or desktop computer.Electronics
Equipment 1300 be also possible to referred to as user equipment, portable electronic device, electronic equipment on knee, table type electronic equipment etc. other
Title.
In general, electronic equipment 1300 includes: processor 1301 and memory 1302.
Processor 1301 may include one or more processing cores, such as 4 core processors, 8 core processors etc..Place
Reason device 1301 can use DSP (Digital Signal Processing, Digital Signal Processing), FPGA (Field-
Programmable Gate Array, field programmable gate array), PLA (Programmable Logic Array, may be programmed
Logic array) at least one of example, in hardware realize.Processor 1301 also may include primary processor and coprocessor, master
Processor is the processor for being handled data in the awake state, also referred to as CPU (Central Processing
Unit, central processing unit);Coprocessor is the low power processor for being handled data in the standby state.?
In some embodiments, processor 1301 can be integrated with GPU (Graphics Processing Unit, image processor),
GPU is used to be responsible for the rendering and drafting of content to be shown needed for display screen.In some embodiments, processor 1301 can also be wrapped
AI (Artificial Intelligence, artificial intelligence) processor is included, the AI processor is for handling related machine learning
Calculating operation.
Memory 1302 may include one or more computer readable storage mediums, which can
To be non-transient.Memory 1302 may also include high-speed random access memory and nonvolatile memory, such as one
Or multiple disk storage equipments, flash memory device.In some embodiments, the non-transient computer in memory 1302 can
Storage medium is read for storing at least one instruction, at least one instruction performed by processor 1301 for realizing this Shen
Please in embodiment of the method provide EMS memory management process.
In some embodiments, electronic equipment 1300 is also optional includes: peripheral device interface 1303 and at least one outside
Peripheral equipment.It can be connected by bus or signal wire between processor 1301, memory 1302 and peripheral device interface 1303.Respectively
A peripheral equipment can be connected by bus, signal wire or circuit board with peripheral device interface 1303.Specifically, peripheral equipment packet
It includes: radio circuit 1304, display screen 1305, CCD camera assembly 1306, voicefrequency circuit 1307, positioning component 1308 and power supply 1309
At least one of.
In some embodiments, electronic equipment 1300 further includes having one or more sensors.One or more sensing
Device includes but is not limited to: acceleration transducer, gyro sensor, pressure sensor, fingerprint sensor, optical sensor and
Proximity sensor.
It will be understood by those skilled in the art that structure shown in Figure 13 does not constitute the restriction to electronic equipment 1300,
It may include perhaps combining certain components than illustrating more or fewer components or being arranged using different components.
In the exemplary embodiment, a kind of computer readable storage medium is additionally provided, is stored in the storage medium
At least one instruction, at least a Duan Chengxu, code set or instruction set, at least one instruction, an at least Duan Chengxu, institute
Code set or instruction set is stated to be loaded by the processor of electronic equipment and executed to realize above-mentioned EMS memory management process.
Optionally, above-mentioned computer readable storage medium can be ROM, random access memory (RAM), CD-ROM, magnetic
Band, floppy disk and optical data storage devices etc..
In the exemplary embodiment, a kind of computer program product is additionally provided, when the computer program product is performed
When, it is used to execute above-mentioned EMS memory management process.
It should be understood that referenced herein " multiple " refer to two or more."and/or", description association
The incidence relation of object indicates may exist three kinds of relationships, for example, A and/or B, can indicate: individualism A exists simultaneously A
And B, individualism B these three situations.Character "/" typicallys represent the relationship that forward-backward correlation object is a kind of "or".Make herein
" first ", " second " and similar word are not offered as any sequence, quantity or importance, and are used only to distinguish
Different component parts.
Above-mentioned the embodiment of the present application serial number is for illustration only, does not represent the advantages or disadvantages of the embodiments.
The above is only the exemplary embodiments of the application, all in spirit herein and original not to limit the application
Within then, any modification, equivalent replacement, improvement and so on be should be included within the scope of protection of this application.
Claims (10)
1. a kind of EMS memory management process, which is characterized in that the described method includes:
First circulation queue is determined according to the capacity requirement of first object object;Wherein, the capacity requirement is used to indicate described
First memory size needed for first object object, the first circulation queue is for storing free memory index;
When being indexed in the first circulation queue there are the free memory, from the front pointer institute of the first circulation queue
The target memory index in the free memory index is read in the first position of instruction, and is updated indicated by the front pointer
First position;
The target memory is indexed corresponding memory source to distribute to the first object object.
2. the method according to claim 1, wherein the front pointer from the first circulation queue is signified
Before reading the target memory index in free memory index in the first position shown, further includes:
According to the size relation between first position number and second position number, calculates and store in the first circulation queue
The quantity of free memory index, the first position number are the corresponding Position Numbers in the first position, described second
Position Number is the corresponding Position Number in the second position indicated by rear pointer in the first circulation queue;
When the quantity of the free memory index stored in the first circulation queue is greater than zero, it is determined that described first follows
There are free memory indexes in ring queue.
3. according to the method described in claim 2, it is characterized in that, described number it with the second position according to first position number
Between size relation, calculate stored in the first circulation queue the free memory index quantity, comprising:
When the second position, number is greater than the first position number, by second position number and the first position
Difference between number is determined as the quantity of the free memory stored in the first circulation queue index;
When the second position, number is less than the first position number, the queue length of the first circulation queue is subtracted
The second position number is numbered and added in the first position, obtains storing in the first circulation queue described with interior
Deposit the quantity of index.
4. the method according to claim 1, wherein the capacity requirement according to first object object determines
One round-robin queue, comprising:
Obtain the corresponding relationship between different round-robin queues and different memory sizes, the corresponding memory size of the round-robin queue,
It is used to indicate the memory size that the free memory stored in the round-robin queue indexes corresponding memory block;
The round-robin queue that memory size is target memory capacity is determined as the first circulation queue, the target memory capacity
Refer to and be greater than first memory size, and the difference between first memory size meets the memory appearance of preset condition
Amount.
5. the method according to claim 1, wherein the capacity requirement according to first object object determines
Before one round-robin queue, further includes:
Detect whether the first object object there is memory to obtain permission;
If it is detected that there is the first object object memory to obtain permission, execute described according to the first object pair
The capacity requirement of elephant determines the step of first circulation queue.
6. method according to any one of claims 1 to 5, which is characterized in that the queue length of the first circulation queue
It is the integer greater than 1 for n, the n;It is described to update first position indicated by the front pointer, comprising:
When the first position, corresponding first position number is less than the n, first position number plus 1 obtain more
The corresponding first position number in the first position after new;
When number is equal to the n when the first position, first position number is updated to 1.
7. method according to any one of claims 1 to 5, which is characterized in that the method also includes:
Second circulation queue is determined according to the release capacity of the second target object;Wherein, the release capacity is used to indicate described
Second memory size of the second target object release, the second circulation queue is for storing free memory index;
Position indicated by the rear pointer of the second circulation queue is updated, and the second circulation queue in the updated
The corresponding memory index of memory source to be released is stored in position indicated by rear pointer;
Discharge the memory source to be released.
8. a kind of memory management device, which is characterized in that described device includes:
First determining module, for determining first circulation queue according to the capacity requirement of first object object;Wherein, the capacity
First memory size needed for demand is used to indicate the first object object, the first circulation queue is for storing in available
Deposit index;
Index obtains module, for being followed from described first when indexing in the first circulation queue there are the free memory
The target memory index in the free memory index is read in first position indicated by the front pointer of ring queue;
Location updating module, for updating first position indicated by the front pointer;
Memory allocating module is distributed for the target memory to be indexed corresponding memory source to the first object object.
9. a kind of electronic equipment, which is characterized in that the electronic equipment includes processor and memory, is stored in the memory
Have at least one instruction, at least a Duan Chengxu, code set or instruction set, at least one instruction, an at least Duan Chengxu,
The code set or instruction set are loaded by the processor and are executed to realize memory as described in any one of claim 1 to 7
Management method.
10. a kind of computer readable storage medium, which is characterized in that be stored at least one in the computer readable storage medium
Item instruction, at least a Duan Chengxu, code set or instruction set, at least one instruction, an at least Duan Chengxu, the code
Collection or instruction set are loaded by processor and are executed to realize EMS memory management process as described in any one of claim 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910290004.0A CN110209493B (en) | 2019-04-11 | 2019-04-11 | Memory management method, device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910290004.0A CN110209493B (en) | 2019-04-11 | 2019-04-11 | Memory management method, device, electronic equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110209493A true CN110209493A (en) | 2019-09-06 |
CN110209493B CN110209493B (en) | 2023-08-01 |
Family
ID=67785292
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910290004.0A Active CN110209493B (en) | 2019-04-11 | 2019-04-11 | Memory management method, device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110209493B (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112596889A (en) * | 2020-12-29 | 2021-04-02 | 凌云光技术股份有限公司 | Method for managing chained memory based on state machine |
CN112732448A (en) * | 2021-01-18 | 2021-04-30 | 国汽智控(北京)科技有限公司 | Memory space allocation method and device and computer equipment |
CN112799842A (en) * | 2021-02-01 | 2021-05-14 | 安徽芯纪元科技有限公司 | Memory management method for embedded operating system of digital signal processor |
CN114240730A (en) * | 2021-12-20 | 2022-03-25 | 苏州凌云视界智能设备有限责任公司 | Processing method for detection data in AOI detection equipment |
CN116521606A (en) * | 2023-06-27 | 2023-08-01 | 太初(无锡)电子科技有限公司 | Task processing method, device, computing equipment and storage medium |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5873089A (en) * | 1995-09-04 | 1999-02-16 | Hewlett-Packard Company | Data handling system with circular queue formed in paged memory |
CN101140531A (en) * | 2007-10-10 | 2008-03-12 | 中兴通讯股份有限公司 | Quick-speed application EMS memory method |
CN101493787A (en) * | 2009-02-18 | 2009-07-29 | 中兴通讯股份有限公司 | Internal memory operation management method and system |
US20150169237A1 (en) * | 2013-12-17 | 2015-06-18 | International Business Machines Corporation | Method and device for managing a memory |
US20190073295A1 (en) * | 2017-09-04 | 2019-03-07 | SK Hynix Inc. | Memory system and operating method of the same |
CN109522121A (en) * | 2018-11-15 | 2019-03-26 | 郑州云海信息技术有限公司 | A kind of memory application method, device, terminal and computer readable storage medium |
-
2019
- 2019-04-11 CN CN201910290004.0A patent/CN110209493B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5873089A (en) * | 1995-09-04 | 1999-02-16 | Hewlett-Packard Company | Data handling system with circular queue formed in paged memory |
CN101140531A (en) * | 2007-10-10 | 2008-03-12 | 中兴通讯股份有限公司 | Quick-speed application EMS memory method |
CN101493787A (en) * | 2009-02-18 | 2009-07-29 | 中兴通讯股份有限公司 | Internal memory operation management method and system |
US20150169237A1 (en) * | 2013-12-17 | 2015-06-18 | International Business Machines Corporation | Method and device for managing a memory |
US20190073295A1 (en) * | 2017-09-04 | 2019-03-07 | SK Hynix Inc. | Memory system and operating method of the same |
CN109522121A (en) * | 2018-11-15 | 2019-03-26 | 郑州云海信息技术有限公司 | A kind of memory application method, device, terminal and computer readable storage medium |
Non-Patent Citations (1)
Title |
---|
徐延东;华蓓;: "面向GPU的内存管理与应用", 电子技术, no. 07, pages 86 - 90 * |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112596889A (en) * | 2020-12-29 | 2021-04-02 | 凌云光技术股份有限公司 | Method for managing chained memory based on state machine |
CN112596889B (en) * | 2020-12-29 | 2023-09-29 | 凌云光技术股份有限公司 | Method for managing chained memory based on state machine |
CN112732448A (en) * | 2021-01-18 | 2021-04-30 | 国汽智控(北京)科技有限公司 | Memory space allocation method and device and computer equipment |
CN112799842A (en) * | 2021-02-01 | 2021-05-14 | 安徽芯纪元科技有限公司 | Memory management method for embedded operating system of digital signal processor |
CN114240730A (en) * | 2021-12-20 | 2022-03-25 | 苏州凌云视界智能设备有限责任公司 | Processing method for detection data in AOI detection equipment |
CN114240730B (en) * | 2021-12-20 | 2024-01-02 | 苏州凌云光工业智能技术有限公司 | Processing method of detection data in AOI detection equipment |
CN116521606A (en) * | 2023-06-27 | 2023-08-01 | 太初(无锡)电子科技有限公司 | Task processing method, device, computing equipment and storage medium |
CN116521606B (en) * | 2023-06-27 | 2023-09-05 | 太初(无锡)电子科技有限公司 | Task processing method, device, computing equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN110209493B (en) | 2023-08-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110209493A (en) | EMS memory management process, device, electronic equipment and storage medium | |
CN103003791B (en) | Distribute the system and method for the part sharing storehouse | |
CN111324427B (en) | Task scheduling method and device based on DSP | |
CN104272278B (en) | Method for updating shared caches and multi-threaded processing system | |
CN107729135B (en) | Method and device for parallel data processing in sequence | |
CN108496161A (en) | Data buffer storage device and control method, data processing chip, data processing system | |
US20150067279A1 (en) | Data processing system and method for operating a data processing system | |
CN107273042A (en) | Deduplication DRAM system algorithm framework | |
CN104281535B (en) | A kind for the treatment of method and apparatus of mapping table in internal memory | |
CN102831068A (en) | Memory operating record processing method and device | |
CN106776809A (en) | A kind of data query method and system | |
CN111274039A (en) | Memory recovery method and device, storage medium and electronic equipment | |
CN107608885A (en) | Localization method, device, system and the readable storage medium storing program for executing of memory overflow point | |
CN106775493A (en) | A kind of storage control and I/O Request processing method | |
CN103543901B (en) | The method and apparatus generating menu | |
CN109298888B (en) | Queue data access method and device | |
CN111666150B (en) | Storage space allocation method and device, terminal and computer readable storage medium | |
US9395982B1 (en) | Atomic memory operations on an N-way linked list | |
CN110162395A (en) | A kind of method and device of Memory Allocation | |
CN108563507A (en) | A kind of EMS memory management process, device, equipment and readable storage medium storing program for executing | |
CN110515860A (en) | The address of storing data identifies method, system and device in a kind of memory | |
CN107291627A (en) | A kind of data processing method and electronic equipment | |
CN108733489A (en) | Data processing method, device, electronic equipment and storage medium | |
CN110163155B (en) | Face data processing method and device, electronic equipment and readable storage medium | |
US9418175B2 (en) | Enumeration of a concurrent data structure |
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 |