CN106201904A - Method and device for internal memory garbage reclamation - Google Patents

Method and device for internal memory garbage reclamation Download PDF

Info

Publication number
CN106201904A
CN106201904A CN201610531791.XA CN201610531791A CN106201904A CN 106201904 A CN106201904 A CN 106201904A CN 201610531791 A CN201610531791 A CN 201610531791A CN 106201904 A CN106201904 A CN 106201904A
Authority
CN
China
Prior art keywords
internal memory
state
timer
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.)
Granted
Application number
CN201610531791.XA
Other languages
Chinese (zh)
Other versions
CN106201904B (en
Inventor
李强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN201610531791.XA priority Critical patent/CN106201904B/en
Publication of CN106201904A publication Critical patent/CN106201904A/en
Application granted granted Critical
Publication of CN106201904B publication Critical patent/CN106201904B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0253Garbage 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 device for internal memory garbage reclamation.This method being used for internal memory garbage reclamation includes: with the process of an application program as parent process, replicates the subprocess generating described parent process;Make described subprocess that the internal memory rubbish in described application program to be marked, to calculate the internal memory rubbish in described application program;And make described subprocess be stored in a shared drive address of described internal memory rubbish.The method, it can be avoided that long-time blocking occurs in process, improves program feature.

Description

Method and device for internal memory garbage reclamation
Technical field
The present invention relates to calculator memory management technique field, in particular to a kind of for internal memory garbage reclamation Method and device.
Background technology
Script (Python, Lua etc.) relies on its many advantage, has obtained widely in field of program development Use.Script typically has garbage reclamation mechanism, and it generally uses " labelling-removing (Mark-and-Sweep) " algorithm. This algorithm is divided into two steps and performs when carrying out internal memory garbage reclamation: the 1st step, marking phase, travels through all of object, if Up to (Reachable), namely still have object quoting it, then be marked as up to;2nd step, removes the stage, again Traverse object, if it find that certain object be not flagged as up to, then reclaimed.This process is referred to as once " entirely reclaiming " mistake Journey.This process will not be by other task any or event interrupt before being finished, and program cannot do other during this period Thing, causes the blocking time to program long, thus leverages the performance of program.
Blocking time to program when although each script is in order to reduce garbage reclamation as far as possible, all devise the calculation of uniqueness Method, the reference count method used such as Python, the substep garbage reclamation mechanism etc. that Lua language uses, its main thought is Once long rubbish is calculated and is divided into multiple discrete little calculation procedure.But first, garbage collection algorithms is distributed to Each timeslice up, inevitably affects the performance that program performs.Secondly, at present for each script all there is no one The technology of kind can avoid using " entirely reclaiming " mechanism completely, and therefore once there is " recovery entirely ", program can be blocked longer one section continuously Time, especially with the increasing of memory object in program, " entirely reclaim " being time-consumingly continuously increased of rubbish every time, block time-consuming the most not Controlled.
Be only used for strengthening the understanding to the background of the present invention in information above-mentioned disclosed in described background section, therefore it Can include not constituting the information to 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 internal memory garbage reclamation, it is possible to avoid process long-time resistance occur Plug, improves the performance of program.
Other characteristics of the present invention and advantage will be apparent from by detailed description below, or partially by the present invention Practice and acquistion.
According to an aspect of the present invention, it is provided that a kind of method for internal memory garbage reclamation, including: a) with one application journey The process of sequence is parent process, replicates the subprocess generating parent process;B) make subprocess that the internal memory rubbish in application program is carried out Labelling, to calculate the internal memory rubbish in application program;And it is shared interior c) to make subprocess that the address of internal memory rubbish is stored in one In depositing.
According to an embodiment of the present invention, said method also includes: d) when determining that subprocess is by the ground of internal memory rubbish When location is stored in shared drive, from shared drive, takes out the address of internal memory rubbish, and be saved in local storage.
According to an embodiment of the present invention, said method also includes: e) internal memory rubbish is performed garbage collection operation.
According to an embodiment of the present invention, also included before step e): start a first timer;And in step D) also include after or before step e): current state is set to the third state;Wherein, step e) also includes: when first When being not fully complete garbage collection operation before timer expiry, suspend garbage collection operation, record and return current state;And work as When completing garbage collection operation before first timer time-out, current state is set to the first state, records and return and work as Front state.
According to an embodiment of the present invention, said method also includes: when the current state returned is the third state, open A dynamic second timer;And when the current state returned is the first state, start one the 3rd intervalometer;Wherein the 3rd timing The duration threshold value of device is more than the duration threshold value of second timer.
According to an embodiment of the present invention, also include after step a): current state is set to the second state, and Record and return current state;Said method also includes: when the state returned is the second state, start second timer.
According to an embodiment of the present invention, said method also includes: when second timer time-out and current state are the During three condition, perform step e);When second timer time-out and current state are the second state, perform described step d).With And when the 3rd timer expiry, perform step a).
According to a further aspect in the invention, it is provided that a kind of device for internal memory garbage reclamation, including process replication mould Block, for the process of an application program as parent process, replicates the subprocess generating parent process;Rubbish mark module, is used for making Internal memory rubbish in application program is marked by subprocess, to calculate the internal memory rubbish in application program;And address deposits Storage module, for making subprocess be stored in a shared drive address of internal memory rubbish.
According to an embodiment of the present invention, said apparatus also includes: address reproduction module, for when determining that subprocess is When the address of internal memory rubbish is stored in shared drive, from shared drive, takes out the address of internal memory rubbish, and be saved to In local storage.
According to an embodiment of the present invention, said apparatus also includes: garbage reclamation module, for performing internal memory rubbish Garbage collection operation.
According to an embodiment of the present invention, said apparatus also includes: first timer module, for when garbage reclamation mould Before block performs garbage collection operation to internal memory rubbish, start a first timer;And state setting module, for working as address After the address of internal memory rubbish is preserved to local storage by replication module, or when internal memory rubbish is held by garbage reclamation module Before row garbage collection operation, current state is set to the third state;Wherein, garbage reclamation module is additionally operable to when the first timing When being not fully complete garbage collection operation before device time-out, suspend garbage collection operation, record and return current state;And when first When completing garbage collection operation before timer expiry, current state is set to the first state, records and return current shape State.
According to an embodiment of the present invention, said apparatus also includes: second timer module, for current when return When state is the third state, start a second timer;And the 3rd timer module, for being the when the current state returned During one state, start one the 3rd intervalometer;Wherein the duration threshold value of the 3rd intervalometer is more than the duration threshold value of second timer.
According to an embodiment of the present invention, state setting module is additionally operable to generate parent process when process replication module replicates Subprocess after, current state is set to the second state, and records and return current state;And second timer module It is additionally operable to, when the state returned is the second state, start described second timer.
Internal memory waste disposal method according to the present invention, uses process replication technology, and current process is multiple as parent process Make subprocess, utilize subprocess that the internal memory rubbish in application program is marked so that parent process can be entered at subprocess During row rubbish labelling properly functioning the most blocked, so can reduce time-consuming in script of garbage collection operation, thorough The end, avoids the long-time obstruction being likely to occur, thus improves the performance of program.
It should be appreciated that it is only exemplary that above general description and details hereinafter describe, can not be limited this Invention.
Accompanying drawing explanation
Describing its example embodiment in detail by referring to accompanying drawing, above and other target of the present invention, feature and advantage will Become more fully apparent.
Fig. 1 is according to a kind of method flow diagram for internal memory garbage reclamation shown in an illustrative embodiments.
Fig. 2 is for the method flow diagram of internal memory garbage reclamation according to the another kind shown in an illustrative embodiments.
Fig. 3 is for the method flow diagram of internal memory garbage reclamation according to another shown in an illustrative embodiments.
Fig. 4 is for the method flow diagram of internal memory garbage reclamation according to another shown in an illustrative embodiments.
Fig. 5 is the block diagram according to a kind of device for internal memory garbage reclamation shown in an illustrative embodiments.
Fig. 6 is for the block diagram of the device of internal memory garbage reclamation according to the another kind shown in an illustrative embodiments.
Fig. 7 is for the block diagram of the device of internal memory garbage reclamation according to another shown in an illustrative embodiments.
Fig. 8 is for the block diagram of the device of internal memory garbage reclamation according to another shown in an illustrative embodiments.
Detailed description of the invention
It is described more fully with example embodiment referring now to accompanying drawing.But, example embodiment can be with multiple shape Formula is implemented, and is not understood as limited to example set forth herein;On the contrary, it is provided that these embodiments make the present invention will more Fully and completely, and by the design of example embodiment those skilled in the art is conveyed to all sidedly.Accompanying drawing is only the present invention Schematic illustrations, be not necessarily drawn to scale.Reference identical in figure represents same or similar part, thus Repetition thereof will be omitted.
Additionally, described feature, structure or characteristic can be combined in one or more enforcement in any suitable manner In mode.In the following description, it is provided that many details thus be given and embodiments of the present invention fully understood.So And, it will be appreciated by persons skilled in the art that and can put into practice technical scheme and omit in described specific detail one Or more, or other method, constituent element, device, step etc. can be used.In other cases, it is not shown in detail or describes Known features, method, device, realize or operate avoiding that a presumptuous guest usurps the role of the host and each aspect of the present invention is thickened.
Fig. 1 is according to a kind of method flow diagram for internal memory garbage reclamation shown in an illustrative embodiments.Such as Fig. 1 Shown in, the method 10 for internal memory garbage reclamation includes:
In step S101, with the process of an application program as parent process, replicate the subprocess generating described parent process.
Such as, in Unix/Linux system, can be working as of application program rapidly by calling of fork system Front process copies a subprocess, and former process is then referred to as parent process.Preferably, use Copy on write technology, thus realize The fastest reproduction speed.
In step s 102, subprocess is made the internal memory rubbish in application program to be marked, to calculate application program In internal memory rubbish.
Subprocess owing to replicating out from parent process has data duplicate with parent process, and in script " rubbish " has a critically important characteristic, it is simply that the most also quoting it, therefore object become rubbish it After, except garbage collection algorithms, any other code is impossible to change its state, and it, by always rubbish, therefore may be used To use subprocess that the internal memory rubbish in application program is marked, " the mark being previously mentioned such as above-mentioned " background technology " part Note " operation, to calculate all internal memory rubbish in application program.
Additionally, replicating subprocess out is two completely self-contained processes with parent process, will not interact.Therefore, When subprocess carries out rubbish marking operation, parent process will not be blocked, it is also possible to properly functioning.
In step s 103, subprocess is made to be stored in a shared drive address of internal memory rubbish.
Calculated internal memory rubbish address, after completing rubbish marking operation, is recorded, is stored in one by subprocess In shared drive, so that the internal memory rubbish of mark can be reclaimed by parent process.
The method for internal memory garbage reclamation of embodiment of the present invention, uses process replication technology, current process is made Copy subprocess for parent process, utilize subprocess that the internal memory rubbish in application program is marked so that parent process is permissible During subprocess carries out rubbish labelling properly functioning the most blocked, so can reduce garbage collection operation in script Time-consuming, thoroughly avoid the long-time obstruction being likely to occur, thus improve the performance of program.
It will be clearly understood that present disclosure describe how to be formed and use particular example, but the principle of the present invention is not limited to Any details of these examples.On the contrary, teaching based on present disclosure, these principles can be applied to many other Embodiment.
Fig. 2 is for the method flow diagram of internal memory garbage reclamation according to the another kind shown in an illustrative embodiments.As Shown in Fig. 2, the method 20 for internal memory garbage reclamation includes:
In step s 201, with the process of an application program as parent process, replicate the subprocess generating described parent process.
In step S202, subprocess is made the internal memory rubbish in application program to be marked, to calculate application program In internal memory rubbish.
In step S203, subprocess is made to be stored in a shared drive address of internal memory rubbish.
Above-mentioned steps is identical with step S101 in the method 10 shown in Fig. 1~S103, does not repeats them here.
In step S204, when determining that the address of described internal memory rubbish is stored in described shared drive by subprocess, From shared drive, take out the address of internal memory rubbish, and be saved in local storage.
The address that will be stored in the internal memory rubbish in shared drive preserves to local storage, can avoid at follow-up rubbish Remove and removal process constantly accesses this shared drive, and cause the existence time of this shared drive.Additionally, due to other enter Journey can also access this shared drive, if owing to other processes cause the damage of this shared drive and cause rubbish address Mistake, it will cause serious consequence.
In step S205, above-mentioned internal memory rubbish is performed garbage collection operation.
During garbage collection operation, if the internal memory rubbish being marked is too much, then 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 Time to process blocking, in certain embodiments, it is also possible to perform garbage reclamation clear operation several times.For example, it is possible to it is logical Spending the maximum obstruction time that arranges realizes.After starting refuse cleaning operation, start timing, if the duration of refuse cleaning exceedes The maximum obstruction time, then in spite of by complete for current all internal memory refuse cleanings, all suspend current refuse cleaning behaviour Make, so that current process continues its normal operating.After waiting for a period of time, again carry out refuse cleaning operation, continue clear Except internal memory rubbish that is the most marked but that be not eliminated, the same time removed still is limited by the maximum obstruction time.Constantly Repeat the operation of above-mentioned gradation refuse cleaning, until by complete for all internal memory refuse cleanings of institute's labelling, then it represents that complete epicycle rubbish Reclaimer operation.Step S204 and S205 such as can be performed by parent process (i.e. current process).
According to the method for internal memory garbage reclamation of embodiment of the present invention, perform rubbish labelling utilizing subprocess After operation, performed garbage collection operation by parent process further.When " entirely reclaiming " operation such that it is able to avoid to parent process long Between block, improve program performance.
Fig. 3 is for the method flow diagram of internal memory garbage reclamation according to another shown in an illustrative embodiments.As Shown in Fig. 3, the method 30 for internal memory garbage reclamation includes:
In step S301, it is judged that current state, if current state is the first state, then perform step S302;If Current state is the second state, then perform step S307;If current state is the third state, then perform step S311.
According to the progress of garbage reclamation, three kinds of current states can be provided with:
First state, such as, named " can not start " state, the current garbage reclamation not starting a new round of expression.From Do not started garbage reclamation or complete one take turns garbage reclamation after all can be in this state.
Second state, such as can named " just at labelling " state, representing that duplicated subprocess is calculating can return The garbage object received.
The third state, such as can named " removing " state, represent parent process (i.e. application program when advance Journey) recyclable rubbish that marking according to subprocess (i.e. being carried out by this parent process is duplicated) is purged operation.
In step s 302, with the process of application program as parent process, replicate the subprocess generating described parent process.
If current state is the first state is " beginning " state, then carry out the internal memory refuse cleaning operation of a new round. For example, it is possible to call fork system to create a subprocess.Fork system calls use copy-on-write technology, can be the fastest Fast copies a living process.Former process is referred to as parent process, and the process out that replicates is referred to as subprocess.
In step S303, current state is set to the second state and returns current state.
After subprocess replicates, such as, by parent process, current state can be set to the second state i.e. " just at labelling " State, and return current state.The step for will not block application program, hereafter parent process can be properly functioning, proceeds Other computings.
In step s 304, make subprocess that the internal memory rubbish in application program is marked.
The marking operation in " labelling-removing " computing is carried out, to calculate the internal memory rubbish in application program by subprocess Rubbish.
In step S305, subprocess is made to be stored in a shared drive address of internal memory rubbish.
After subprocess marks all internal memory rubbish, the address of internal memory rubbish is stored in shared drive.
In step S306, exit this subprocess.
After completing above-mentioned internal memory rubbish marking operation, subprocess exits.
In step S307, it is judged that whether subprocess exits, without exiting, then perform step S308;Otherwise, perform Step S309.
Namely judge whether subprocess has calculated that all internal memory rubbish in application program, and by the address of internal memory rubbish It is stored in shared drive.
For example, it is possible to call whether duplicated subprocess during waitpid function judges epicycle refuse cleaning moves back Go out.Waitpid function can be set to not block by parameter, and i.e. no matter the most whether subprocess has logged out, and returns the most immediately Return result.Result according to returning may determine that whether subprocess has logged out.
In step S308, keep and return current state.
Now, current state remains in that to be the second state i.e. " just at labelling " state.
In step S309, from shared drive, take out internal memory rubbish address, preserve to local storage.
Such as, by parent process after confirming that calculating is complete, the address of garbage object is taken out from shared drive and protects Deposit to local storage, for follow-up refuse cleaning.
In step S310, current state is set to the third state.
It is " removing " state that current state is set to the third state.
In step S311, start a first timer.
The overlong time problem caused to prevent from once removing all internal memory rubbish, can arrange an intervalometer, should The duration threshold value of intervalometer is arranged to the maximum obstruction time, thus limits the time of each refuse cleaning.
In some embodiments, it is also possible to realized by other timing modes, as started timing in this step, work as meter Time when reaching this maximum obstruction time, stop the operation of current refuse cleaning, residual refuse then proceeds in subsequent operation.
In step S312, perform garbage collection operation.
Parent process is according to the rubbish list preserved, the garbage object in loop cleaning parent process.In order to prevent once The long-time obstruction that the rubbish that clears all is likely to result in, the most only removes a number of garbage object.
In step S313, it is judged that whether complete garbage collection operation before first timer time-out, if completing rubbish Rubbish reclaimer operation, then perform step S314;Otherwise, step S315 is performed.
In step S314, current state is set to the first state, records and return current state.
After completing all garbage reclamation, it is " beginning " state that current state is set to the first state, represents this Wheel garbage collection operation completes.
In step S315, suspend garbage collection operation, and return current state.
Suspending garbage collection operation, the third state keeping current is " removing " state, and returns current state.
Fig. 4 is for the method flow diagram of internal memory garbage reclamation according to another shown in an illustrative embodiments.Fig. 4 Shown method 40 periodically calls the method 30 shown in Fig. 3, to enter for the current state returned according to the method 30 shown in Fig. 3 Row internal memory garbage reclamation.Such as, in actual applications, if the method shown in Fig. 3 30 is implemented as an internal memory garbage reclamation Function, then the method 40 shown in Fig. 4 is for periodically calling this function, realizes periodically calling this function as arranged intervalometer, or Person is additionally to start a thread to call this function.Specifically, as shown in Figure 4, the method 40 for internal memory garbage reclamation is wrapped Include:
In step S400, perform the garbage collection operation of a new round.
In step S401, perform the internal memory garbage collection operation in the method 30 shown in Fig. 3.
It should be noted that the when of internal memory garbage collection operation in performing the method 30 shown in Fig. 3, system can be prohibited Use original rubbish recovering method.
In step S402, it is judged that the current state of return, i.e. " mark if the current state returned is the second state Note " state or be " removing " state for the third state, then execution step S403;If the current state returned is first State i.e. " not starting state ", then performs step S404.
In step S403, start second timer.
The most complete garbage reclamation action, namely remove markd rubbish, it is referred to as taking turns garbage reclamation.And In order to avoid single reclaims the long-time obstructing problem caused, garbage collection operation can be taken turns one and be cut into again multi-pass operation. Operation all allows to arrange a maximum obstruction time every time, has exceeded this time, and corresponding garbage collection operation will suspend.
If the current state returned is the second state " just at labelling " or the third state " is removed ", then show rubbish Collection process is that internal memory rubbish is marked by subprocess, or is not fully complete institute due to the restriction of maximum obstruction time There is a recovery of internal memory rubbish, need after a preset duration threshold value, then carry out reclaimer operation next time.
The record of this preset duration threshold value can be realized by this second timer, or can also be real by other timing modes Existing, the present invention is not limited.
The duration threshold value of second timer can be configured according to current system load situation by user.As hope is tried one's best Do not affect systematic function, the most such as, can only use each second 1 millisecond to be purged work, namely respectively by second timer It is set to 1 second and 1 millisecond with the duration threshold value of first timer.And it is it desired to comparatively fast to discharge all rubbish, the most permissible Every 100 milliseconds are called once, remove rubbish 10 milliseconds every time, namely respectively by the duration threshold of second timer and first timer Value is set to 100 milliseconds and 10 milliseconds.
In step s 404, the 3rd intervalometer is started.
If returning " beginning " state when result is the first state, then represent epicycle garbage reclamation and be complete, accurate The standby garbage collection operation starting a new round.One duration threshold value can be set according to the load of system, when duration is beyond this duration During threshold value, start again at the garbage collection operation of a new round.This duration threshold value such as can be realized by the 3rd intervalometer record, Or can also be realized by other timing modes, the present invention is not limited.
The duration threshold value of the 3rd intervalometer can set according to the loading condition of current system, and its duration threshold value Duration threshold value more than second timer.
When the 3rd timer expiry, then enter step S400, perform the garbage collection operation of a new round.
It will be appreciated by those skilled in the art that all or part of step realizing above-mentioned embodiment is implemented as being held by CPU The computer program of row.When this computer program is performed by CPU, it is above-mentioned that the said method that performing the present invention provides is limited Function.Described program can be stored in a kind of computer-readable recording medium, and this storage medium can be read only memory, Disk or CD etc..
Further, it should be noted that above-mentioned accompanying drawing is only according to included by the method for exemplary embodiment of the invention Process schematically illustrates rather than limits purpose.It can be readily appreciated that above-mentioned process shown in the drawings is not intended that or limits these The time sequencing processed.It addition, be also easy to understand, these process can be such as either synchronously or asynchronously to perform in multiple modules 's.
Following for apparatus of the present invention embodiment, may be used for performing the inventive method embodiment.Real for apparatus of the present invention Execute the details not disclosed in example, refer to the inventive method embodiment.
Fig. 5 is the block diagram according to a kind of device for internal memory garbage reclamation shown in an illustrative embodiments.Such as Fig. 5 Shown in, the device 50 for internal memory garbage reclamation includes: process replication module 501, rubbish mark module 502 and address storage mould Block 503.
Wherein, process replication module 501 is for the process of an application program as parent process, replicating the son generating parent process Process.
After duplication completes, subprocess is exactly two completely self-contained processes with parent process, will not interact.
Rubbish mark module 502, for making subprocess be marked the internal memory rubbish in application program, is answered to calculate With the internal memory rubbish in program.
Now parent process performs as usual, the subprocess replicating out carry out the calculating of rubbish, and subprocess is with parent process also Row runs, and subprocess calculates all recuperable rubbish, and records the address of internal memory rubbish.
Address memory module 503 is for making subprocess be stored in shared drive the address of internal memory rubbish.
The device for internal memory garbage reclamation of embodiment of the present invention, uses process replication technology, current process is made Copy subprocess for parent process, utilize subprocess that the internal memory rubbish in application program is marked so that parent process is permissible During subprocess carries out rubbish labelling properly functioning the most blocked, so can reduce garbage collection operation in script Time-consuming, thoroughly avoid the long-time obstruction being likely to occur, thus improve the performance of program.
Fig. 6 is for the block diagram of the device of internal memory garbage reclamation according to the another kind shown in an illustrative embodiments.As Shown in Fig. 6, the device 60 for internal memory garbage reclamation may further comprise: address reproduction module 604 and garbage reclamation module 605。
Wherein address reproduction module 604 is for when determining that the address of internal memory rubbish is stored in shared drive by subprocess Time, from shared drive, take out the address of internal memory rubbish, and be saved in local storage.
Garbage reclamation module 605 is for performing garbage collection operation to internal memory rubbish.
According to the device for internal memory garbage reclamation of embodiment of the present invention, perform rubbish labelling utilizing subprocess After operation, performed garbage collection operation by parent process further.When " entirely reclaiming " operation such that it is able to avoid to parent process long Between block, improve program performance.
Fig. 7 is for the block diagram of the device of internal memory garbage reclamation according to another shown in an illustrative embodiments.As Shown in Fig. 7, compared to the device 60 shown in Fig. 6, the device 70 for internal 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 performs garbage collection operation to internal memory rubbish, Start first timer.
State setting module 707 is for preserving the address of internal memory rubbish to local storage when address replication module 604 After in, or when internal memory rubbish is performed before garbage collection operation by garbage reclamation module 605, current state is set to the Three condition.
In certain embodiments, garbage reclamation module 605 is additionally operable to be not fully complete rubbish before first timer time-out and returns Bring drill to an end when making, suspend garbage collection operation, record and return current state;And completed rubbish before first timer time-out During rubbish reclaimer operation, current state is set to the first state, records and return current state.
Fig. 8 is for the block diagram of the device of internal memory garbage reclamation according to another shown in an illustrative embodiments.As Shown in Fig. 8, compared to the device 70 shown in Fig. 7, the device 80 for internal memory garbage reclamation may further comprise: second timer Module 808 and the 3rd timer module 809.
Wherein second timer module 808 is for when the current state returned is the third state, starts one second timing Device.
3rd timer module 809 is for when the current state returned is the first state, starting one the 3rd intervalometer.
State setting module 707 is additionally operable to after process replication module 501 replicates the subprocess of generation parent process, ought Front state is set to the second state, and records and return described current state.
Second timer module 808 is additionally operable to, when the state returned is the second state, start second timer.
It should be noted that the block diagram shown in above-mentioned accompanying drawing is functional entity, it is not necessary to must with physically or logically Independent entity is corresponding.Can use software form to realize these functional entitys, or in one or more hardware modules or Integrated circuit realizes these functional entitys, or realizes 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 be realized by software, it is also possible to realizes by the way of software combines necessary hardware.Therefore, according to the present invention The technical scheme of embodiment can embody with the form of software product, this software product can be stored in one non-volatile In property storage medium (can be CD-ROM, USB flash disk, portable hard drive etc.) or on network, including some instructions so that a calculating Equipment (can be personal computer, server, mobile terminal or the network equipment etc.) performs according to embodiment of the present invention Method.
More than it is particularly shown and described the illustrative embodiments of the present invention.It should be appreciated that the present invention does not limits In detailed construction described herein, set-up mode or implementation method;It is included in claims on the contrary, it is intended to contain Spirit and scope in various amendments and equivalence arrange.

Claims (13)

1. the method for internal memory garbage reclamation, it is characterised in that including:
A) with the process of an application program as parent process, the subprocess generating described parent process is replicated;
B) make described subprocess that the internal memory rubbish in described application program is marked, to calculate in described application program Internal memory rubbish;And
C) described subprocess is made to be stored in a shared drive address of described internal memory rubbish.
Method the most according to claim 1, it is characterised in that also include:
D) when determining that the address of described internal memory rubbish is stored in described shared drive by described subprocess, in described sharing Deposit the address of middle taking-up described internal memory rubbish, and be saved in local storage.
Method the most according to claim 2, it is characterised in that also include:
E) described internal memory rubbish is performed garbage collection operation.
Method the most according to claim 3, it is characterised in that also included before described step e): start one first fixed Time device;And
Also include after described step d) or before described step e): current state is set to the third state;
Wherein, described step e) also includes: when being not fully complete described garbage collection operation before described first timer time-out, temporarily Stop described garbage collection operation, record and return described current state;And completed before described first timer time-out During described garbage collection operation, current state is set to the first state, records and return described current state.
Method the most according to claim 4, it is characterised in that also include:
When the described current state returned is the described third state, start a second timer;And
When the described current state returned is described first state, start one the 3rd intervalometer;
The duration threshold value of wherein said 3rd intervalometer is more than the duration threshold value of described second timer.
Method the most according to claim 5, it is characterised in that also include after described step a): current state is set It is set to the second state, and records and return described current state;Described method also includes: when the described state returned is described the During two-state, start described second timer.
Method the most according to claim 6, it is characterised in that also include:
When the overtime and described current state of described second timer is the described third state, perform described step e);
When the overtime and described current state of described second timer is described second state, perform described step d).And
When described 3rd timer expiry, perform described step a).
8. the device for internal memory garbage reclamation, it is characterised in that including:
Process replication module, for the process of an application program as parent process, replicates the subprocess generating described parent process;
Rubbish mark module, for making described subprocess be marked the internal memory rubbish in described application program, to calculate Internal memory rubbish in described application program;And
Address memory module, for making described subprocess be stored in a shared drive address of described internal memory rubbish.
Device the most according to claim 8, it is characterised in that also include:
Address reproduction module, for when determining that the address of described internal memory rubbish is stored in described shared drive by described subprocess Time, from described shared drive, take out the address of described internal memory rubbish, and be saved in local storage.
Device the most according to claim 9, it is characterised in that also include:
Garbage reclamation module, for performing garbage collection operation to described internal memory rubbish.
11. devices according to claim 10, it is characterised in that also include:
First timer module, for when described garbage reclamation module to described internal memory rubbish perform described garbage collection operation it Before, start a first timer;And
State setting module, for preserving the address of described internal memory rubbish to local storage when described address reproduction module Afterwards, or before described garbage reclamation module performs described garbage collection operation to described internal memory rubbish, by current state It is set to the third state;
Wherein, described garbage reclamation module was additionally operable to before described first timer time-out be not fully complete described garbage collection operation Time, suspend described garbage collection operation, record and return described current state;And it is complete before described first timer time-out When having become described garbage collection operation, current state is set to the first state, records and return described current state.
12. devices according to claim 11, it is characterised in that also include:
Second timer module, for when the described current state returned is the described third state, starting a second timer; And
3rd timer module, for when the described current state returned is described first state, starting one the 3rd intervalometer;
The duration threshold value of wherein said 3rd intervalometer is more than the duration threshold value of described second timer.
13. devices according to claim 12, it is characterised in that described state setting module is additionally operable to when described process is multiple After molding block replicates the subprocess generating described parent process, current state is set to the second state, and records and return institute State current state;And described second timer module is additionally operable to, when the described state returned is described second state, start Described second timer.
CN201610531791.XA 2016-06-30 2016-06-30 Method and device for memory garbage reclamation Active CN106201904B (en)

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 true CN106201904A (en) 2016-12-07
CN106201904B 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)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109690485A (en) * 2018-08-24 2019-04-26 袁振南 Rubbish recovering method, computer and storage medium based on data structure
CN110673956A (en) * 2019-09-24 2020-01-10 Oppo广东移动通信有限公司 Recovery thread creating method and device, computer equipment and storage medium
CN112463626A (en) * 2020-12-10 2021-03-09 网易(杭州)网络有限公司 Memory leak positioning method and device, computer equipment and storage medium
CN112764891A (en) * 2019-10-21 2021-05-07 青岛海信移动通信技术股份有限公司 Electronic terminal and method for controlling application
CN112783656A (en) * 2021-01-29 2021-05-11 网易(杭州)网络有限公司 Memory management method, medium, device and computing equipment
CN113157452A (en) * 2021-04-20 2021-07-23 腾讯科技(深圳)有限公司 Application service request method and device, computer equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102346755A (en) * 2010-07-30 2012-02-08 财团法人工业技术研究院 Scalable and parallel garbage collection method and system
US20130262532A1 (en) * 2012-03-28 2013-10-03 Quantum Corporation Garbage collection for virtual environments

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102346755A (en) * 2010-07-30 2012-02-08 财团法人工业技术研究院 Scalable and parallel garbage collection method and system
US20130262532A1 (en) * 2012-03-28 2013-10-03 Quantum Corporation Garbage collection for virtual environments

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
GUSTAVO RODRIGUEZ-RIVERA 等: ""Nonintrusive Cloning Garbage Collection with Stock Operating System Support"", 《SOFTWARE:PRACTICE AND EXPERIENCE》 *

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109690485A (en) * 2018-08-24 2019-04-26 袁振南 Rubbish recovering method, computer and storage medium based on data structure
CN109690485B (en) * 2018-08-24 2023-08-18 袁振南 Garbage collection method based on data structure, computer and storage medium
CN110673956A (en) * 2019-09-24 2020-01-10 Oppo广东移动通信有限公司 Recovery thread creating method and device, computer equipment and storage medium
CN112764891A (en) * 2019-10-21 2021-05-07 青岛海信移动通信技术股份有限公司 Electronic terminal and method for controlling application
CN112764891B (en) * 2019-10-21 2022-11-11 青岛海信移动通信技术股份有限公司 Electronic terminal and method for controlling application
CN112463626A (en) * 2020-12-10 2021-03-09 网易(杭州)网络有限公司 Memory leak positioning method and device, computer equipment and storage medium
CN112463626B (en) * 2020-12-10 2023-07-11 网易(杭州)网络有限公司 Memory leakage positioning method and device, computer equipment and storage medium
CN112783656A (en) * 2021-01-29 2021-05-11 网易(杭州)网络有限公司 Memory management method, medium, device and computing equipment
CN112783656B (en) * 2021-01-29 2024-04-30 杭州网易智企科技有限公司 Memory management method, medium, device and computing equipment
CN113157452A (en) * 2021-04-20 2021-07-23 腾讯科技(深圳)有限公司 Application service request method and device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN106201904B (en) 2019-03-26

Similar Documents

Publication Publication Date Title
CN106201904A (en) Method and device for internal memory garbage reclamation
CN105446834B (en) The generation method and device of virtual machine snapshot
US20190294602A1 (en) Data scrubbing method and apparatus, and computer readable storage medium
CN106933501A (en) Duplicate is created at user-defined time point
CN105144113B (en) Recover to apply from snapshot
JP5160006B2 (en) Method and apparatus for performing atomic updates using a logical flash memory device
CN101467134B (en) Method and arrangement for processing transactions in a flash type memory device
CN106484906A (en) A kind of distributed objects storage system flash back method and device
CN106155839B (en) A kind of method and apparatus for Backup Data
CN110807064A (en) Data recovery device in RAC distributed database cluster system
CN107590144A (en) A kind of file memory method and terminal
CN101086717B (en) System and method for storing transient state information
CN108733567A (en) The monitoring method and system of software resource leak case
CN107643962A (en) A kind of backup method of data storage, device, equipment and readable storage medium storing program for executing
CN108804337A (en) The method, apparatus and computer storage media of memory garbage reclamation
CN108287761B (en) Memory recovery method and device, terminal equipment and computer readable storage medium
CN114490193B (en) Recovery method and device for heterogeneous redundant system
CN109032762A (en) Virtual machine retrogressive method and relevant device
CN111177028B (en) Method and equipment for dynamic multi-level caching
CN108052415A (en) A kind of malware detection platform quick recovery method and system
CN111090491B (en) Virtual machine task state recovery method and device and electronic equipment
CN113448774A (en) Method, system, device and medium for optimizing copy-on-write storage snapshot management
CN108089942A (en) A kind of data backup, restoration methods and device
CN105095197A (en) Method and device for processing data
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