CN106201904B - Method and device for memory garbage reclamation - Google Patents
Method and device for memory garbage reclamation Download PDFInfo
- Publication number
- CN106201904B CN106201904B CN201610531791.XA CN201610531791A CN106201904B CN 106201904 B CN106201904 B CN 106201904B CN 201610531791 A CN201610531791 A CN 201610531791A CN 106201904 B CN106201904 B CN 106201904B
- Authority
- CN
- China
- Prior art keywords
- state
- timer
- memory
- rubbish
- current state
- 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.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/0223—User address space allocation, e.g. contiguous or non contiguous base addressing
- G06F12/023—Free address space management
- G06F12/0253—Garbage collection, i.e. reclamation of unreferenced memory
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Memory System (AREA)
Abstract
This application discloses a kind of method and devices for memory garbage reclamation.The method for being used for memory garbage reclamation includes: using the process of an application program as parent process, and duplication generates the subprocess of the parent process;The subprocess is marked to the memory rubbish in the application program, to calculate the memory rubbish in the application program;And it is stored in the subprocess in one shared drive the address of the memory rubbish.This method, which can be avoided process, to be occurred blocking for a long time, improves program feature.
Description
Technical field
The present invention relates to calculator memory administrative skill field, in particular to a kind of for memory garbage reclamation
Method and device.
Background technique
Scripting language (Python, Lua etc.) relies on its many advantage, has obtained widely in field of program development
It uses.Scripting language generally has garbage reclamation mechanism, generallys use " label-removing (Mark-and-Sweep) " algorithm.
The algorithm can be divided into two steps when carrying out memory garbage reclamation to execute: step 1, marking phase traverse all objects, if
It is reachable (Reachable), namely still has object quoting it, then is marked as reachable;Step 2, removing stage, again
Traverse object is then recycled if it find that some object is not flagged as reachable.The process is known as primary " Quan Huishou " mistake
Journey.The process will not be by any other task or event interrupt before being finished, and program can not do others during this period
Thing causes the blocking time to program too long, to leverage the performance of program.
Although all devising unique calculation to the blocking time of program when each scripting language is in order to reduce garbage reclamation to the greatest extent
Method, such as the substep garbage reclamation mechanism etc. that the reference count method that Python uses, Lua language use, main thought is
Primary prolonged rubbish calculating is divided into multiple discrete small calculating steps.But firstly, garbage collection algorithms are distributed to
Each timeslice gets on, and inevitably will affect the performance of program execution.Secondly, each scripting language is without one at present
Kind of technology can be avoided completely using " Quan Huishou " mechanism, thus if there is " Quan Huishou " program can continuously block it is one section longer
Time increases especially with memory object in program, and the time-consuming of each " Quan Huishou " rubbish is continuously increased, and obstruction is time-consuming not
Controllably.
Above- mentioned information are only used for reinforcing the understanding to background of the invention, therefore it disclosed in the background technology part
It may include the information not constituted to the prior art known to persons of ordinary skill in the art.
Summary of the invention
The present invention provides a kind of method and device for memory garbage reclamation, and hindering for a long time occurs in the process that can be avoided
Plug, improves the performance of program.
Other characteristics and advantages of the invention will be apparent from by the following detailed description, or partially by the present invention
Practice and acquistion.
According to an aspect of the present invention, a kind of method for memory garbage reclamation is provided, comprising: a) apply journey with one
The process of sequence is parent process, and duplication generates the subprocess of parent process;Carry out subprocess to the memory rubbish in application program
Label, to calculate the memory rubbish in application program;And c) make subprocess that the address deposit one of memory rubbish is shared interior
In depositing.
According to an embodiment of the present invention, the above method further include: d) when determining subprocess by the ground of memory rubbish
When location is stored in shared drive, the address of memory rubbish is taken out from shared drive, and is saved in local storage.
According to an embodiment of the present invention, the above method further include: garbage collection operation e) is executed to memory rubbish.
According to an embodiment of the present invention, before step e) further include: one first timer of starting;And in step
D) after or before step e) further include: set the third state for current state;Wherein, step e) further include: when first
When not completing garbage collection operation before timer expiry, suspends garbage collection operation, record and return to current state;And work as
When completing garbage collection operation before first timer time-out, first state is set by current state, records and returns and work as
Preceding state.
According to an embodiment of the present invention, the above method further include: when the current state of return is the third state, open
A dynamic second timer;And when the current state of return is first state, start a third timer;Wherein third timing
The duration threshold value of device is greater than the duration threshold value of second timer.
According to an embodiment of the present invention, after step a) further include: the second state is set by current state, and
It records and returns to current state;The above method further include: when the state of return is the second state, start second timer.
According to an embodiment of the present invention, the above method further include: when second timer time-out and current state is the
When three condition, step e) is executed;When second timer is overtime and current state is the second state, the step d) is executed.With
And work as third timer expiry, execute step a).
According to another aspect of the present invention, a kind of device for memory garbage reclamation is provided, comprising: process replication mould
Block, for using the process of an application program as parent process, duplication to generate the subprocess of parent process;Rubbish mark module, for making
The memory rubbish in application program is marked in subprocess, to calculate the memory rubbish in application program;And address is deposited
Module is stored up, for being stored in subprocess in one shared drive the address of memory rubbish.
According to an embodiment of the present invention, above-mentioned apparatus further include: address reproduction module has determined subprocess for working as
When by the address deposit shared drive of memory rubbish, the address of memory rubbish is taken out from shared drive, and be saved to
In local storage.
According to an embodiment of the present invention, above-mentioned apparatus further include: garbage reclamation module, for being executed to memory rubbish
Garbage collection operation.
According to an embodiment of the present invention, above-mentioned apparatus further include: first timer module, for working as garbage reclamation mould
Before block executes garbage collection operation to memory rubbish, start a first timer;And state setting module, for working as address
After replication module saves the address of memory rubbish into local storage, or when garbage reclamation module holds memory rubbish
Before row garbage collection operation, the third state is set by current state;Wherein, garbage reclamation module is also used to when the first timing
When not completing garbage collection operation before device time-out, suspends garbage collection operation, record and return to current state;And when first
When completing garbage collection operation before timer expiry, first state is set by current state, records and returns to current shape
State.
According to an embodiment of the present invention, above-mentioned apparatus further include: second timer module, for current when what is returned
When state is the third state, start a second timer;And third timer module, for being the when the current state returned
When one state, start a third timer;Wherein the duration threshold value of third timer is greater than the duration threshold value of second timer.
According to an embodiment of the present invention, state setting module is also used to generate parent process when the duplication of process replication module
Subprocess after, set the second state for current state, and record and return to current state;And second timer module
It is also used to start the second timer when the state of return is the second state.
Memory waste disposal method according to the present invention is answered using process replication technology using current process as parent process
Produce subprocess, the memory rubbish in application program be marked using subprocess, allow parent process subprocess into
Row rubbish is operated normally during marking and is not blocked, can so reduce time-consuming of the garbage collection operation in scripting language, thorough
Bottom avoids the long-time obstruction being likely to occur, to improve the performance of program.
It should be understood that the above general description and the following detailed description are merely exemplary, this can not be limited
Invention.
Detailed description of the invention
Its example embodiment is described in detail by referring to accompanying drawing, above and other target of the invention, feature and advantage will
It becomes more fully apparent.
Fig. 1 is a kind of method flow diagram for memory garbage reclamation shown according to an illustrative embodiments.
Fig. 2 is the method flow diagram that memory garbage reclamation is used for according to the another kind shown in an illustrative embodiments.
Fig. 3 is the method flow diagram that memory garbage reclamation is used for according to another shown in an illustrative embodiments.
Fig. 4 is the method flow diagram that memory garbage reclamation is used for according to another shown in an illustrative embodiments.
Fig. 5 is a kind of block diagram of device for memory garbage reclamation shown according to an illustrative embodiments.
Fig. 6 is the block diagram according to the another kind shown in an illustrative embodiments for the device of memory garbage reclamation.
Fig. 7 is the block diagram according to another shown in an illustrative embodiments for the device of memory garbage reclamation.
Fig. 8 is the block diagram according to another shown in an illustrative embodiments for the device of memory garbage reclamation.
Specific embodiment
Example embodiment is described more fully with reference to the drawings.However, example embodiment can be with a variety of shapes
Formula is implemented, and is not understood as limited to example set forth herein;On the contrary, thesing embodiments are provided so that the present invention will more
Fully and completely, and by the design of example embodiment comprehensively it is communicated to those skilled in the art.Attached drawing is only the present invention
Schematic illustrations, be not necessarily drawn to scale.Identical appended drawing reference indicates same or similar part in figure, thus
Repetition thereof will be omitted.
In addition, described feature, structure or characteristic can be incorporated in one or more implementations in any suitable manner
In mode.In the following description, many details are provided to provide and fully understand to embodiments of the present invention.So
And it will be appreciated by persons skilled in the art that technical solution of the present invention can be practiced and omit one in the specific detail
Or more, or can be using other methods, constituent element, device, step etc..In other cases, it is not shown in detail or describes
Known features, method, apparatus, realization or operation are to avoid a presumptuous guest usurps the role of the host and each aspect of the present invention is made to thicken.
Fig. 1 is a kind of method flow diagram for memory garbage reclamation shown according to an illustrative embodiments.Such as Fig. 1
Shown, the method 10 for memory garbage reclamation includes:
In step s101, using the process of an application program as parent process, duplication generates the subprocess of the parent process.
For example, in Unix/Linux system, it can be by the calling of fork system come rapidly working as application program
Preceding process copies a subprocess, and former process is then referred to as parent process.Preferably, using Copy on write technology, to realize
Very fast reproduction speed.
In step s 102, subprocess is marked to the memory rubbish in application program, to calculate application program
In memory rubbish.
Due to copied from parent process the subprocess come have with the duplicate data of parent process, and in scripting language
" rubbish " has a critically important characteristic, be exactly Anywhere also do not quoting it, therefore object become rubbish it
Afterwards, in addition to garbage collection algorithms, any other code is impossible to change its state, it will be always rubbish, therefore can
The memory rubbish in application program is marked with using subprocess, " the mark that such as above-mentioned " background technique " is partially previously mentioned
Note " operation, to calculate all memory rubbish in application program.
In addition, copying next subprocess and parent process is two completely self-contained processes, will not interact.Therefore,
When subprocess carries out rubbish marking operation, parent process will not be blocked, and can also be operated normally.
In step s 103, be stored in subprocess the address of memory rubbish in one shared drive.
The memory rubbish address being calculated is recorded after completing rubbish marking operation, is stored in one by subprocess
In shared drive so that parent process can the memory rubbish to mark recycle.
The method for memory garbage reclamation of embodiment of the present invention is made current process using process replication technology
Subprocess is copied for parent process, the memory rubbish in application program is marked using subprocess, so that parent process can be with
It operates normally during subprocess carries out rubbish label and is not blocked, can so reduce garbage collection operation in scripting language
Time-consuming, thoroughly avoid be likely to occur long-time obstruction, to improve the performance of program.
It will be clearly understood that the present disclosure describe how being formed and using particular example, but the principle of the present invention is not limited to
These exemplary any details.On the contrary, the introduction based on present disclosure, these principles can be applied to many other
Embodiment.
Fig. 2 is the method flow diagram that memory garbage reclamation is used for according to the another kind shown in an illustrative embodiments.Such as
Shown in Fig. 2, the method 20 for memory garbage reclamation includes:
In step s 201, using the process of an application program as parent process, duplication generates the subprocess of the parent process.
In step S202, subprocess is marked to the memory rubbish in application program, to calculate application program
In memory rubbish.
In step S203, it is stored in subprocess in one shared drive the address of memory rubbish.
Above-mentioned steps are identical as step S101~S103 in method 10 shown in FIG. 1, and details are not described herein.
In step S204, when determining that the address of the memory rubbish is stored in the shared drive by subprocess,
The address of memory rubbish is taken out from shared drive, and is saved in local storage.
The address for the memory rubbish being stored in shared drive is saved to local storage, it can be to avoid in subsequent rubbish
Remove removal process in constantly access this shared drive, and cause the shared drive there are the times.Further, since other into
Journey also accessible shared drive, if leading to rubbish address since other processes cause the damage of the shared drive
Mistake, it will cause serious consequence.
In step S205, garbage collection operation is executed to above-mentioned memory rubbish.
During garbage collection operation, if the memory rubbish being marked is excessive, reset procedure then can be longer, from
And also result in the execution of the obstruction current process of long period.Therefore, in order to further reduce each garbage collection operation
To the time of process blocking, in some embodiments, garbage reclamation clear operation can also be executed several times.For example, can lead to
The one maximum obstruction time of setting is spent to realize.After starting rubbish clear operation, start timing, if the duration that rubbish is removed is more than
The maximum obstruction time suspends current rubbish and removes behaviour then in spite of current all memory rubbish removings are finished
Make, so that current process be made to continue its normal operating.After waiting for a period of time, rubbish clear operation is carried out again, is continued clear
Except memory rubbish that is marked before but not removed, limitation of the time equally removed still by the maximum obstruction time.Constantly
Above-mentioned gradation rubbish clear operation is repeated, is removed until by all memory rubbish marked, then it represents that completes epicycle rubbish
Reclaimer operation.Step S204 and S205 for example can be by parent process (i.e. current process) Lai Zhihang.
The method for memory garbage reclamation of embodiment according to the present invention is marked having executed rubbish using subprocess
After operation, garbage collection operation is further executed by parent process.So as to avoid " Quan Huishou " operation to parent process it is long when
Between block, improve the performance of program.
Fig. 3 is the method flow diagram that memory garbage reclamation is used for according to another shown in an illustrative embodiments.Such as
Shown in Fig. 3, the method 30 for memory garbage reclamation includes:
In step S301, current state is judged, if current state is first state, then follow the steps S302;If
Current state is the second state, thens follow the steps S307;If current state is the third state, S311 is thened follow the steps.
According to the progress of garbage reclamation, can set there are three types of current state:
First state, such as it can be named as " not starting " state, indicate the garbage reclamation for not starting a new round currently.From
Do not start garbage reclamation or completes this state that can all be in after a wheel garbage reclamation.
Second state, such as it can be named as " label " state, indicating that the subprocess copied is calculating can return
The garbage object of receipts.
The third state, such as it can be named as " removing " state, indicating parent process, (i.e. working as application program, advances
Journey) operation is being purged according to the recyclable rubbish that subprocess (progress copied by the parent process) marks.
In step s 302, using the process of application program as parent process, duplication generates the subprocess of the parent process.
If current state is that first state " does not start " state, the memory rubbish clear operation of a new round is carried out.
For example, fork system can be called to create a subprocess.Fork system, which is called, uses copy-on-write technology, can be very fast
Speed copies a same process.Former process is known as parent process, copies the process come and is known as subprocess.
In step S303, the second state is set by current state and returns to current state.
After subprocess replicates, such as current state can be set as the second state by parent process and " marked "
State, and return to current state.The step for will not block application program, hereafter parent process can operate normally, and continue
Other operations.
In step s 304, subprocess is marked to the memory rubbish in application program.
The marking operation in " label-removing " operation is carried out by subprocess, to calculate the memory rubbish in application program
Rubbish.
In step S305, it is stored in subprocess in one shared drive the address of memory rubbish.
It, will be in the address deposit shared drive of memory rubbish after subprocess marks all memory rubbish.
In step S306, the subprocess is exited.
After completing above-mentioned memory rubbish marking operation, subprocess is exited.
In step S307, judge whether subprocess exits, if do not exited, thens follow the steps S308;Otherwise, it executes
Step S309.
Namely judge whether subprocess has calculated that all memory rubbish in application program, and by the address of memory rubbish
It is stored in shared drive.
For example, waitpid function can be called to judge whether the subprocess copied in epicycle rubbish reset procedure moves back
Out.Waitpid function can be set as not blocking by parameter, i.e., regardless of whether subprocess currently has logged out, all return immediately
Return result.It may determine that whether subprocess has logged out according to the result of return.
In step S308, keeps and return to current state.
At this point, current state, which still maintains, " is marking " state for the second state.
In step S309, memory rubbish address is taken out from shared drive, is saved into local storage.
For example, the address of garbage object is taken out and is protected from shared drive after confirmation is calculated and finished by parent process
It deposits into local storage, removes and use for subsequent rubbish.
In step s310, the third state is set by current state.
The third state, which is set, by current state " is removing " state.
In step S311, start a first timer.
Overlong time problem caused by all memory rubbish is once removed in order to prevent, and a timer can be set, it should
The duration threshold value of timer is arranged to the maximum obstruction time, to limit the time that each rubbish is removed.
In some embodiments, it is also possible to be realized by other timing modes, such as starts timing in this step, work as meter
When reaching the maximum obstruction time, stop current rubbish clear operation, residual refuse then continues in subsequent operation.
In step S312, garbage collection operation is executed.
Garbage object of the parent process according to the rubbish list preserved, in loop cleaning parent process.It is primary in order to prevent
The long-time obstruction that the rubbish that clears all may cause, only removes a certain number of garbage objects here.
In step S313, whether garbage collection operation is completed before judging first timer time-out, if completing rubbish
Rubbish reclaimer operation, thens follow the steps S314;Otherwise, step S315 is executed.
In step S314, first state is set by current state, records and returns to current state.
After completing all garbage reclamations, first state is set by current state and " does not start " state, indicates this
Garbage collection operation is taken turns to complete.
In step S315, suspend garbage collection operation, and return to current state.
Suspend garbage collection operation, keeps the current third state " removing " state, and return to current state.
Fig. 4 is the method flow diagram that memory garbage reclamation is used for according to another shown in an illustrative embodiments.Fig. 4
Shown in method 40 for according to Fig.3, method 30 return current state periodically call method 30 shown in Fig. 3, with into
Row memory garbage reclamation.For example, in practical applications, if method shown in Fig. 3 30 is implemented as a memory garbage reclamation
Function, then method 40 shown in Fig. 4 is arranged timer such as to realize and periodically calls the function for periodically calling the function, or
Person is one thread of other starting to call the function.Specifically, as shown in figure 4, the method 40 for memory garbage reclamation is wrapped
It includes:
In step S400, the garbage collection operation of a new round is executed.
In step S401, the memory garbage collection operation in method 30 shown in Fig. 3 is executed.
It should be noted that system can prohibit when executing the memory garbage collection operation in method 30 shown in Fig. 3
With original rubbish recovering method.
In step S402, the current state returned is judged, if the current state returned is that the second state " is being marked
Note " state is " removing " state for the third state, thens follow the steps S403;If the current state returned is first
State is " not starting state ", thens follow the steps S404.
In step S403, start second timer.
Complete garbage reclamation movement every time, namely the markd rubbish of institute is removed, referred to as one wheel garbage reclamation.And
In order to avoid long-time obstructing problem caused by single recycling, a wheel garbage collection operation can be cut into multi-pass operation again.
Operation all allows that a maximum obstruction time is arranged every time, has been more than this time, corresponding garbage collection operation will suspend.
If the current state returned is the second state " label " or the third state " removing ", show rubbish
Collection process be memory rubbish be marked by subprocess, or by the maximum obstruction time limitation and do not complete to institute
There is the recycling of memory rubbish, needs in the reclaimer operation by a preset duration threshold value and then progress next time.
The record of the preset duration threshold value can realize by the second timer, or can also be by other timing modes reality
Existing, invention is not limited thereto.
The duration threshold value of second timer can be configured by user according to current system load situation.As wished as far as possible
System performance is not influenced, then for example can be purged work to only use 1 millisecond each second, namely respectively by second timer
1 second and 1 millisecond are set as with the duration threshold value of first timer.And if it is desired to all rubbish can comparatively fast be discharged, that
Every 100 milliseconds are called once, are removed rubbish every time 10 milliseconds, namely respectively by the duration threshold of second timer and first timer
Value is set as 100 milliseconds and 10 milliseconds.
In step s 404, start third timer.
If returning the result and " not starting " state when being first state, represents epicycle garbage reclamation and completed, it is quasi-
The standby garbage collection operation for starting a new round.One duration threshold value can be set according to the load of system, when duration exceeds the duration
When threshold value, the garbage collection operation of a new round is started again at.The duration threshold value can for example be recorded by third timer and be realized,
Or can also be realized by other timing modes, invention is not limited thereto.
The duration threshold value of the third timer can be set according to the loading condition of current system, and its duration threshold value
Greater than the duration threshold value of second timer.
When third timer expiry, then S400 is entered step, executes the garbage collection operation of a new round.
It will be appreciated by those skilled in the art that realizing that all or part of the steps of above embodiment is implemented as being held by CPU
Capable computer program.When the computer program is executed by CPU, execute above-mentioned defined by the above method provided by the invention
Function.The program can store in a kind of computer readable storage medium, which can be read-only memory,
Disk or CD etc..
Further, it should be noted that above-mentioned attached drawing is only according to the present invention included by the method for illustrative embodiments
Processing schematically illustrates, rather than limits purpose.It can be readily appreciated that above-mentioned processing shown in the drawings does not indicate or limits these
The time sequencing of processing.In addition, being also easy to understand, these processing, which can be, for example either synchronously or asynchronously to be executed in multiple modules
's.
Following is apparatus of the present invention embodiment, can be used for executing embodiment of the present invention method.For apparatus of the present invention reality
Undisclosed details in example is applied, embodiment of the present invention method is please referred to.
Fig. 5 is a kind of block diagram of device for memory garbage reclamation shown according to an illustrative embodiments.Such as Fig. 5
Shown, the device 50 for memory garbage reclamation includes: process replication module 501, rubbish mark module 502 and address storage mould
Block 503.
Wherein, process replication module 501 is used for using the process of an application program as parent process, and duplication generates the son of parent process
Process.
Subprocess and parent process are exactly two completely self-contained processes after the completion of duplication, will not be interacted.
Rubbish mark module 502 is answered for subprocess to be marked to the memory rubbish in application program with calculating
With the memory rubbish in program.
Parent process executes as usual at this time, the calculating of rubbish is carried out by copying the subprocess come, subprocess and parent process are simultaneously
Row operation, subprocess calculates all recuperable rubbish, and records the address of memory rubbish.
Address memory module 503 is used to make subprocess will be in the address deposit shared drive of memory rubbish.
The device for memory garbage reclamation of embodiment of the present invention is made current process using process replication technology
Subprocess is copied for parent process, the memory rubbish in application program is marked using subprocess, so that parent process can be with
It operates normally during subprocess carries out rubbish label and is not blocked, can so reduce garbage collection operation in scripting language
Time-consuming, thoroughly avoid be likely to occur long-time obstruction, to improve the performance of program.
Fig. 6 is the block diagram according to the another kind shown in an illustrative embodiments for the device of memory garbage reclamation.Such as
Shown in Fig. 6, the device 60 for memory garbage reclamation may further comprise: address reproduction module 604 and garbage reclamation module
605。
Wherein address reproduction module 604 is used for when in determining subprocess the address deposit shared drive by memory rubbish
When, the address of memory rubbish is taken out from shared drive, and be saved in local storage.
Garbage reclamation module 605 is used to execute garbage collection operation to memory rubbish.
The device for memory garbage reclamation of embodiment according to the present invention is marked having executed rubbish using subprocess
After operation, garbage collection operation is further executed by parent process.So as to avoid " Quan Huishou " operation to parent process it is long when
Between block, improve the performance of program.
Fig. 7 is the block diagram according to another shown in an illustrative embodiments for the device of memory garbage reclamation.Such as
Shown in Fig. 7, compared to device 60 shown in fig. 6, the device 70 for memory garbage reclamation may further comprise: first timer
Module 706 and state setting module 707.
First timer module 706 is used for before garbage reclamation module 605 executes garbage collection operation to memory rubbish,
Start first timer.
State setting module 707 is used to save the address of memory rubbish to local storage when address replication module 604
In after, or before garbage reclamation module 605 executes garbage collection operation to memory rubbish, set for current state
Three condition.
In some embodiments, garbage reclamation module 605 is also used to not complete rubbish before first timer time-out and return
It brings drill to an end when making, suspends garbage collection operation, record and return to current state;And rubbish is completed before first timer time-out
When rubbish reclaimer operation, first state is set by current state, records and returns to current state.
Fig. 8 is the block diagram according to another shown in an illustrative embodiments for the device of memory garbage reclamation.Such as
Shown in Fig. 8, compared to device 70 shown in Fig. 7, the device 80 for memory garbage reclamation may further comprise: second timer
Module 808 and third timer module 809.
Wherein second timer module 808 is used for when the current state of return is the third state, one second timing of starting
Device.
Third timer module 809 is used to start a third timer when the current state of return is first state.
State setting module 707 is also used to work as after process replication module 501 replicates the subprocess for generating parent process
Preceding state is set as the second state, and records and return to the current state.
Second timer module 808 is also used to start second timer when the state of return is the second state.
It should be noted that above-mentioned block diagram shown in the drawings is functional entity, not necessarily must with physically or logically
Independent entity is corresponding.Can realize these functional entitys using software form, or in one or more hardware modules or
These functional entitys are realized in integrated circuit, or are realized in heterogeneous networks and/or processor device and/or microcontroller device
These functional entitys.
Through the above description of the embodiments, those skilled in the art is it can be readily appreciated that example described herein is implemented
Mode can also be realized by software realization in such a way that software is in conjunction with necessary hardware.Therefore, according to the present invention
The technical solution of embodiment can be embodied in the form of software products, which can store non-volatile at one
Property storage medium (can be CD-ROM, USB flash disk, mobile hard disk etc.) in or network on, including some instructions are so that a calculating
Equipment (can be personal computer, server, mobile terminal or network equipment etc.) executes embodiment according to the present invention
Method.
It is particularly shown and described exemplary embodiments of the present invention above.It should be appreciated that the present invention is unlimited
In detailed construction described herein, set-up mode or implementation method;On the contrary, it is intended to cover included in appended claims
Spirit and scope in various modifications and equivalence setting.
Claims (7)
1. a kind of method for memory garbage reclamation characterized by comprising
A) using the process of an application program as parent process, duplication generates the subprocess of the parent process;
The subprocess is marked to the memory rubbish in the application program, to calculate in the application program
Memory rubbish;
Be stored in the subprocess address of the memory rubbish in one shared drive;
D) when determining that the address of the memory rubbish is stored in the shared drive by the subprocess, out of described share
The middle address for taking out the memory rubbish is deposited, and is saved in local storage;And
E) parent process is made to execute garbage collection operation to the memory rubbish;
Wherein before the step e) further include: one first timer of starting;And
After the step d) or before the step e) further include: set the third state for current state;
Wherein, the step e) further include: when not completing the garbage collection operation before the first timer time-out, temporarily
Stop the garbage collection operation, record and returns to the current state;And it is completed before the first timer time-out
When the garbage collection operation, first state is set by current state, record and returns to the current state.
2. the method according to claim 1, wherein further include:
When the current state of return is the third state, start a second timer;And
When the current state of return is the first state, start a third timer;
Wherein the duration threshold value of the third timer is greater than the duration threshold value of the second timer.
3. according to the method described in claim 2, it is characterized in that, after the step a) further include: set current state
It is set to the second state, and records and returns to the current state;The method also includes: when the state of return is described the
When two-state, start the second timer.
4. according to the method described in claim 3, it is characterized by further comprising:
When second timer time-out and when the current state is the third state, the step e) is executed;
When second timer time-out and when the current state is second state, the step d) is executed;And
When the third timer expiry, the step a) is executed.
5. a kind of device for memory garbage reclamation characterized by comprising
Process replication module, for using the process of an application program as parent process, duplication to generate the subprocess of the parent process;
Rubbish mark module, for the subprocess to be marked to the memory rubbish in the application program, to calculate
Memory rubbish in the application program;
Address memory module, for being stored in the subprocess in one shared drive the address of the memory rubbish;
Address reproduction module, for the address of the memory rubbish to be stored in the shared drive when the determining subprocess
When, the address of the memory rubbish is taken out from the shared drive, and be saved in local storage;
Garbage reclamation module, for making the parent process execute garbage collection operation to the memory rubbish;
First timer module, for when the garbage reclamation module to the memory rubbish execute the garbage collection operation it
Before, start a first timer;And
State setting module, for saving the address of the memory rubbish into local storage when the address reproduction module
Later, or before the garbage reclamation module executes the garbage collection operation to the memory rubbish, by current state
It is set as the third state;
Wherein, the garbage reclamation module is also used to not complete the garbage collection operation before the first timer time-out
When, suspend the garbage collection operation, records and return to the current state;And it is complete before the first timer time-out
When at the garbage collection operation, first state is set by current state, record and returns to the current state.
6. device according to claim 5, which is characterized in that further include:
Second timer module, for starting a second timer when the current state of return is the third state;
And
Third timer module, for starting a third timer when the current state of return is the first state;
Wherein the duration threshold value of the third timer is greater than the duration threshold value of the second timer.
7. device according to claim 6, which is characterized in that the state setting module is also used to when the process replication
After module duplication generates the subprocess of the parent process, the second state is set by current state, and records and returns described
Current state;And the second timer module is also used to start institute when the state of return is second state
State second timer.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610531791.XA CN106201904B (en) | 2016-06-30 | 2016-06-30 | Method and device for memory garbage reclamation |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610531791.XA CN106201904B (en) | 2016-06-30 | 2016-06-30 | Method and device for memory garbage reclamation |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106201904A CN106201904A (en) | 2016-12-07 |
CN106201904B true CN106201904B (en) | 2019-03-26 |
Family
ID=57472992
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610531791.XA Active CN106201904B (en) | 2016-06-30 | 2016-06-30 | Method and device for memory garbage reclamation |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106201904B (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109690485B (en) * | 2018-08-24 | 2023-08-18 | 袁振南 | Garbage collection method based on data structure, computer and storage medium |
CN110673956B (en) * | 2019-09-24 | 2022-04-15 | Oppo广东移动通信有限公司 | Recovery thread creating method and device, computer equipment and storage medium |
CN112764891B (en) * | 2019-10-21 | 2022-11-11 | 青岛海信移动通信技术股份有限公司 | Electronic terminal and method for controlling application |
CN112463626B (en) * | 2020-12-10 | 2023-07-11 | 网易(杭州)网络有限公司 | Memory leakage positioning method and device, computer equipment and storage medium |
CN112783656B (en) * | 2021-01-29 | 2024-04-30 | 杭州网易智企科技有限公司 | Memory management method, medium, device and computing equipment |
CN113157452B (en) * | 2021-04-20 | 2023-07-21 | 腾讯科技(深圳)有限公司 | Application service request method, device, computer equipment and storage medium |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102346755A (en) * | 2010-07-30 | 2012-02-08 | 财团法人工业技术研究院 | Scalable and parallel garbage collection method and system |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10095616B2 (en) * | 2012-03-28 | 2018-10-09 | Quantum Corporation | Garbage collection for virtual environments |
-
2016
- 2016-06-30 CN CN201610531791.XA patent/CN106201904B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102346755A (en) * | 2010-07-30 | 2012-02-08 | 财团法人工业技术研究院 | Scalable and parallel garbage collection method and system |
Non-Patent Citations (1)
Also Published As
Publication number | Publication date |
---|---|
CN106201904A (en) | 2016-12-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106201904B (en) | Method and device for memory garbage reclamation | |
CN105446834B (en) | The generation method and device of virtual machine snapshot | |
KR102074113B1 (en) | Managing object lifetime in a cyclic graph | |
CN102460401B (en) | Change is utilized to follow the tracks of the technology of carrying out System recover | |
EP2972874A1 (en) | Recovery of application from snapshot | |
CN104424015A (en) | Virtual machine management method and virtual machine management device | |
CN109144428B (en) | Garbage recycling method, device and medium applied to solid state disk | |
CN112463437B (en) | Service recovery method, system and related components of storage cluster system offline node | |
CN113254536A (en) | Database transaction processing method, system, electronic device and storage medium | |
CN108763102A (en) | A kind of rubbish recovering method and device of solid state disk | |
CN105243340B (en) | It is a kind of to prevent the method and system that data are accidentally deleted in HBase | |
US8930318B1 (en) | Systems and methods for handling interruptions while updating of an electronic device | |
CN108804337A (en) | The method, apparatus and computer storage media of memory garbage reclamation | |
CN109992492A (en) | Log recording method, device, equipment and the readable storage medium storing program for executing of functional module | |
CN102131002B (en) | A kind of data in mobile phone treating method and apparatus | |
CN105740098A (en) | Determination method and system for stale data among backup data | |
CN113515346A (en) | Storage volume residual data cleaning method and device | |
CN114490193B (en) | Recovery method and device for heterogeneous redundant system | |
CN109032762B (en) | Virtual machine backtracking method and related equipment | |
CN105550328A (en) | Processing method and device of stale data | |
JP4395496B2 (en) | Dump method and dump device | |
CN110008681A (en) | Access control method, equipment and system | |
CN109828950A (en) | Data protection method, management system, server and readable storage medium | |
CN108089942A (en) | A kind of data backup, restoration methods and device | |
CN113419864B (en) | Application memory management method, device, equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |