Nothing Special   »   [go: up one dir, main page]

CN106648882A - Garbage recycling method and device based on virtual machine - Google Patents

Garbage recycling method and device based on virtual machine Download PDF

Info

Publication number
CN106648882A
CN106648882A CN201510740849.7A CN201510740849A CN106648882A CN 106648882 A CN106648882 A CN 106648882A CN 201510740849 A CN201510740849 A CN 201510740849A CN 106648882 A CN106648882 A CN 106648882A
Authority
CN
China
Prior art keywords
memory space
memory
space
size
enliven
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
CN201510740849.7A
Other languages
Chinese (zh)
Other versions
CN106648882B (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.)
Loongson Technology Corp Ltd
Original Assignee
Loongson Technology Corp 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 Loongson Technology Corp Ltd filed Critical Loongson Technology Corp Ltd
Priority to CN201510740849.7A priority Critical patent/CN106648882B/en
Publication of CN106648882A publication Critical patent/CN106648882A/en
Application granted granted Critical
Publication of CN106648882B publication Critical patent/CN106648882B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5061Partitioning or combining of resources
    • G06F9/5077Logical partitioning of resources; Management or configuration of virtualized resources
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System (AREA)

Abstract

The embodiment of the invention provides a garbage recycling method and device based on a virtual machine. The method comprises the following steps that after it is determined that a first storage space is filled with novel objects created by an application program, all active objects in the first storage space and a second storage space at the current moment are stored into a third storage space; after it is determined that all the active objects are stored into the third storage space, clearing up the first storage space and the second storage space; according to the size, accounting for the storage space, of all the active objects, the size of the second storage space and the size of the third storage space are reset, and the second storage space and the third storage space are subjected to switch processing. According to the method, the pile space utilization rate can be increased, and the performance of the application program is improved.

Description

Rubbish recovering method and device based on virtual machine
Technical field
The present embodiments relate to memory technology, more particularly to a kind of rubbish recovering method based on virtual machine And device.
Background technology
The memory management of java applet is completed by Java Virtual Machine.In application program implementation procedure, such as The application thread of fruit application program cannot continue to distribute new object in Java heap, and Java Virtual Machine will Triggering garbage reclamation, reclaims the internal memory not used, so that the Memory Allocation process of subsequent new objects can It is smoothed out.
Garbage collection algorithms are replicated as the one kind in garbage collection algorithms, it realizes that process is mainly:Will Heap storage space average is divided into two parts, and it is new right that Part I memory space is used for the distribution of current application thread As Part II memory space then as reserved storage space, enliven right during garbage reclamation for preserving As.When Part I memory space is filled with, virtual machine triggering garbage reclamation, Part I memory space In all objects that enliven can be copied in Part II memory space, and Part I memory space meeting All reclaimed, then Part I memory space and Part II memory space are exchanged, so as to next rubbish Rubbish is reclaimed and used.Virtual machine is by retaining the storage sky for enlivening object and reclaiming inactive object occupancy Between mode, the work of garbage reclamation is completed, so as to reach the purpose for completing memory management.
However, because java application is in running, most of new object for creating will soon Become inactive object, therefore when garbage reclamation occurs, the number for enlivening object only accounts for whole newborn right As very little part, if reserved storage space is identical with the storage size of distribution new object, cause Heap memory space cannot be fully used, and distribute the limited storage space of new object so that garbage reclamation Frequency becomes big, and the performance of application program is low.
The content of the invention
The embodiment of the present invention provides a kind of rubbish recovering method and device based on virtual machine, empty to improve heap Between utilization rate, improve application program performance.
In a first aspect, the present invention provides a kind of rubbish recovering method based on virtual machine, wherein, virtual machine Heap space include for store activity periods less than predetermined period object memory block of new generation, it is described Memory block of new generation is included for storing the first memory space of the new object of application program establishment, for protecting Deposit the second memory space for enlivening object and the 3rd reserved storage sky survived during last garbage reclamation Between, methods described includes:
After it is determined that the new object that the application program is created is filled with first memory space, will be current All in first memory space described in moment and second memory space enliven object and store to described In 3rd memory space;
It is determined that all enliven after object stores the 3rd memory space, first storage is emptied Space and second memory space;
According to it is described it is all enliven object shared by memory space size, reset second memory space Size and the 3rd memory space size, and to second memory space and the described 3rd Memory space swaps process.
Second aspect, the present invention provides a kind of garbage recovery device based on virtual machine, wherein, the void The heap space of plan machine include for store activity periods less than predetermined period object memory block of new generation, The memory block of new generation is included for storing the first memory space of the new object of application program establishment, using The second memory space for enlivening object and the reserved the 3rd survived when last garbage reclamation is preserved is deposited Storage space, described device includes:
Determining module, for it is determined that the new object that creates of the application program is by first memory space After being filled with, will be all active in the first memory space described in current time and second memory space Object is stored into the 3rd memory space;
Module is emptied, for it is determined that all enliven after object stores the 3rd memory space, clearly Empty first memory space and second memory space;
Processing module, for according to it is described it is all enliven object shared by memory space size, reset institute The size of the second memory space and the size of the 3rd memory space are stated, and it is empty to the described second storage Between and the 3rd memory space swap process.
The present embodiment provide the rubbish recovering method based on virtual machine and device, the method by it is determined that Application program create new object the first memory space is filled with after, by the memory space of current time first with And second all objects that enliven in memory space store into the 3rd memory space;It is determined that all of work Jump object is stored to after the 3rd memory space, empties the first memory space and the second memory space;Root It is empty to the second memory space and the 3rd storage according to the total size that object is enlivened in current garbage collection procedure Between reset, and exchange process has been carried out to the second memory space and the 3rd memory space, make The 3rd memory space that must be reserved can be matched with the total size for enlivening object, realize self-adaptative adjustment heap Space size, heap space makes full use of.
Description of the drawings
In order to be illustrated more clearly that the embodiment of the present invention or technical scheme of the prior art, below will be to reality Apply the accompanying drawing to be used needed for example or description of the prior art to be briefly described, it should be apparent that, under Accompanying drawing in the description of face is some embodiments of the present invention, for those of ordinary skill in the art, On the premise of not paying creative labor, can be with according to these other accompanying drawings of accompanying drawings acquisition.
Fig. 1 is flow chart of the present invention based on the rubbish recovering method embodiment one of virtual machine;
Fig. 2 is flow chart of the present invention based on the rubbish recovering method embodiment two of virtual machine;
Fig. 3 is flow chart of the present invention based on the rubbish recovering method embodiment three of virtual machine;
Fig. 4 is structural representation of the present invention based on the garbage recovery device embodiment one of virtual machine;
Fig. 5 is structural representation of the present invention based on the garbage recovery device embodiment two of virtual machine.
Specific embodiment
To make purpose, technical scheme and the advantage of the embodiment of the present invention clearer, below in conjunction with this Accompanying drawing in bright embodiment, is clearly and completely described to the technical scheme in the embodiment of the present invention, Obviously, described embodiment is a part of embodiment of the invention, rather than the embodiment of whole.It is based on Embodiment in the present invention, those of ordinary skill in the art are obtained under the premise of creative work is not made The every other embodiment for obtaining, belongs to the scope of protection of the invention.
Garbage reclamation is the key concept of memory management in JAVA programmings, JAVA virtual machine internal memory pipe Reason mechanism is referred to as garbage reclamation mechanism, to track the object being currently in use and find and reclaim no longer to make Object.The mechanism can effectively take precautions against two danger that may occur in dynamic memory distribution, because interior Deposit that rubbish is excessive and internal memory that cause exhausts, and the internal memory caused by the release of inappropriate internal memory illegally draws With.
The operation principle of garbage reclamation mechanism is, by monitoring the running status of each object (including Shen Please, quote, be cited, assignment etc.), accurately and timely discharge inactive object, the inactive pair of release The principle of elephant is that the object is not cited.Java carries out memory management by the way of object reference graph of a relation, From the beginning of root set, traverse object adduction relationship figure judges which object meets garbage reclamation to garbage reclamation Condition (i.e. the object is unreachable, is inactive object), then discharge inactive object shared by storage Space.Self-adaptative adjustment heap space size will be illustrated how using detailed embodiment below, realize heap Space makes full use of.
Fig. 1 is flow chart of the present invention based on the rubbish recovering method embodiment one of virtual machine.The present embodiment Virtual machine heap space include for store activity periods less than predetermined period object the Cenozoic storage Area, memory block of new generation is included for storing the first memory space of the new object of application program establishment, using The second memory space for enlivening object and the reserved the 3rd survived when last garbage reclamation is preserved is deposited Storage space.The executive agent of the present embodiment is that, based on the garbage recovery device of virtual machine, the device can lead to Cross software and/or hardware is realized, the device can be embedded in the equipment such as computer and realize, the device may be used also To be the virtual machine created as Jave application programs.As shown in figure 1, the method includes:
Step 101, it is determined that the application program create new object first memory space is filled with Afterwards, all in the first memory space described in current time and second memory space are enlivened into object Store into the 3rd memory space;
Step 102, it is determined that all of enliven after object stores the 3rd memory space, empty First memory space and second memory space;
Step 103, according to it is all enliven object shared by memory space size, reset and described second deposit The size in storage space and the size of the 3rd memory space, and to second memory space and institute State the 3rd memory space and swap process.
During implementing, heap space is divided into the present embodiment into memory block of new generation and old generation deposits Storage area, wherein, memory block of new generation is used to store object of the activity periods less than predetermined period, old generation Memory block is used to store object of the activity periods more than predetermined period.
It will be understood by those skilled in the art that during implementing, if only included in heap space Memory block of new generation, the present embodiment can also complete self-adaptative adjustment heap space size, realize heap space Make full use of.
Specifically, memory block of new generation includes the first storage for storing the new object of application program establishment Space (Eden areas), for preserving the second memory space (From for enlivening object survived during garbage reclamation Area) and reserved the 3rd memory space (To areas).
During implementing, in a step 101, application program is deposited in running first Storage distributes new object in space, it is determined that the new object that application program is created deposits first memory space Man Shi, triggers garbage collection procedure, suspends the implementation procedure of application program, is then closed according to object reference System's figure, will enliven side of the object by copy in the memory space of current time first and the second memory space Formula is stored to the 3rd memory space.
In a step 102, it is determined that it is all enliven object store to after the 3rd memory space, empty first Memory space and the second memory space.
In step 103, according to it is all enliven object shared by memory space size, by second storage The size of the size in space and the 3rd memory space, is reset so that the first storage after replacement is empty Between size with reset after the second memory space size with all memory spaces enlivened shared by object Size it is identical.Then process is swapped to the second memory space and the 3rd memory space, i.e., The second memory space for emptying becomes the 3rd memory space, has been filled with the 3rd memory space for enlivening object Become the second memory space, so far, garbage reclamation flow process terminates, start the implementation procedure of application program.
During implementing, analyze a large amount of java applications and understand, java application is in fortune After row a period of time, garbage reclamation is enlivened the total size of object and is substantially the same when occurring, therefore according to working as The total size of object is enlivened in front garbage collection procedure, the second memory space and the 3rd memory space are entered Replacement is gone, and exchange process has been carried out to the second memory space and the 3rd memory space so that be pre- The 3rd memory space for staying can be matched with the total size for enlivening object, realize self-adaptative adjustment heap space Size, heap space makes full use of.
Further, after the size of the size and the 3rd memory space that reset the second memory space, Can also be empty by the remaining storage in memory block of new generation in addition to the second memory space and the 3rd memory space Between as the first memory space.
It will be understood by those skilled in the art that when the size of the 3rd memory space enlivens object much larger than all During shared size, the second memory space and the 3rd memory space are reset, and the Cenozoic is deposited Residual memory space in storage area in addition to the second memory space and the 3rd memory space is empty as the first storage Between when, then increase the first memory space so that the first memory space can store more application programs The new object for creating, so as to reduce the frequency of garbage reclamation, improves the performance of application program.
The present embodiment is by after it is determined that the new object that application program is created is filled with the first memory space, inciting somebody to action All objects that enliven in the memory space of current time first and the second memory space are stored to the 3rd storage In space;It is empty the first storage it is determined that all of object that enlivens is stored to after the 3rd memory space, is emptied Between and the second memory space;According to the total size that object is enlivened in current garbage collection procedure, to second Memory space and the 3rd memory space are reset, and to the second memory space and the 3rd storage Space has carried out exchange process so that the 3rd reserved memory space can be with the total size for enlivening object Match somebody with somebody, realize self-adaptative adjustment heap space size, heap space makes full use of.
Fig. 2 is flow chart of the present invention based on the rubbish recovering method embodiment two of virtual machine.The present embodiment On the basis of Fig. 1 embodiments, will be explained in all enlivening object when the 3rd memory space can not be stored When, the rubbish recovering method of the present embodiment.As shown in Fig. 2 the method that the present embodiment is provided includes:
Step 201, it is determined that the application program create new object first memory space is filled with Afterwards, all in the first memory space described in current time and second memory space are enlivened into object Store into the 3rd memory space;
Step 202, it is determined that the 3rd memory space is filled with, all of object that enlivens all is not stored During to three memory space, discharge stored empty to the 3rd storage in first memory space Between the memory space enlivened shared by object, and to the remaining free memory of first memory space Process of contracing is carried out, the free memory after processing that contracts is obtained;
Step 203, the object that enlivens not stored to the 3rd memory space is stored to the place of contracing In free memory after reason;
Step 204, storing to described it is determined that not storing to the object that enlivens of the 3rd memory space After first memory space, empty in second memory space and first memory space and contractd except described The memory space outside free memory after process;
Step 205, according to it is all enliven object shared by memory space size, reset and described second deposit The size in storage space and the size of the 3rd memory space, and to second memory space and institute State the 3rd memory space and swap process.
Step 201 in the present embodiment is similar with the step 101 shown in Fig. 1, step 205 and Fig. 1 institutes The step of showing embodiment 104 is similar to, and here is omitted for the present embodiment.
In step 202., when it is determined that the 3rd memory space is filled with, all of object that enlivens all is not stored During to three memory spaces, because some enlivens object storage to the 3rd in the first memory space In memory space, thus in the first memory space release be stored on the 3rd memory space enliven right As shared memory space, now, there is discontinuous idle storage space in the first memory space, will Discontinuous idle storage space contracts to one end of the first memory space in first memory space, is contracted And the free memory after processing.
In step 203, according to object reference graph of a relation, enlivening to the 3rd memory space will not stored Object is stored into the free memory after processing that contracts.It will be understood by those skilled in the art that due to The second memory space and the 3rd memory space in this example is adjusted using adaptive mode, therefore, Even if the 3rd memory space cannot be stored and all of enliven object, but the quantity for enlivening object that cannot be stored Also it is considerably less, during the free memory into the first memory space can be stored completely.
In step 204, it is determined that do not store to the 3rd memory space enliven object store to After first memory space, empty available after processing except contracing in the second memory space and the first memory space Memory space outside memory space.It will be understood by those skilled in the art that after application program launching, When triggering garbage reclamation flow process next time, it is empty that the new object that application program is created can be stored in the first storage Between except contract process after free memory in addition to memory space in.
The present embodiment can not store all processing procedures when enlivening object to the 3rd memory space and be different from now There is technology, in the prior art, the object that enlivens that the 3rd memory space is not stored can be stored to old generation In memory block, due to old age for store in memory block activity periods it is shorter enliven object, so causing It is old higher for the garbage reclamation frequency of memory block, reduce the performance of application program.
And the present embodiment, in three memory space inadequates, adopts process of contracing in garbage collection procedure Mode carry out garbage reclamation process, store it is remaining enliven object when, it is not necessary to taking old generation deposits The memory space of storage area, reduces to old age for garbage reclamation frequency.
Fig. 3 is flow chart of the present invention based on the rubbish recovering method embodiment three of virtual machine.The present embodiment On the basis of Fig. 1 and Fig. 2 embodiments, the detailed process of the rubbish recovering method of the present invention is carried out in detail Describe in detail bright.The method of the present embodiment includes:
Step 301, determine application program create new object the first memory space is filled with;
Step 302, triggering garbage reclamation flow process, suspend the implementation procedure of application program;
Step 303, all in the memory space of current time first and the second memory space are enlivened into right As storing into the 3rd memory space;
Step 304, judge the 3rd memory space whether can deposit it is all enliven object, if so, perform Step 305, if it is not, execution step 306;
Step 305, it is determined that all enliven after object stores the 3rd memory space, empty institute State the first memory space and second memory space;
Step 306, discharge in the first memory space and stored to enliven object to the 3rd memory space Shared memory space, and the remaining free memory to the first memory space carries out process of contracing, and obtains To the free memory after processing that contracts;
Step 307, by do not store to the 3rd memory space enliven object store to contract process after can With in memory space;
Step 308, it is determined that do not store to the 3rd memory space enliven object storing to first storage Behind space, empty in the second memory space and the first memory space except the free memory after processing that contracts Outside memory space;
Step 309, according to it is all enliven object shared by memory space size, reset the second storage empty Between size and the 3rd memory space size;
Step 310, process is swapped to the second memory space and the 3rd memory space, start application The implementation procedure of program.
To sum up, the present embodiment is deposited according to the total size that object is enlivened in current garbage collection procedure to second The size of storage space and the 3rd memory space is reset, and to the second memory space and the 3rd Memory space has carried out exchange process so that the 3rd reserved memory space can with enliven the total big of object Little matching, realizes self-adaptative adjustment heap space size, and heap space makes full use of, and in the 3rd storage During insufficient space, garbage reclamation process is carried out by the way of process of contracing, remaining enliven right storing As when, it is not necessary to take the old memory space for memory block, reduce to old age for garbage reclamation frequency.
Fig. 4 is structural representation of the present invention based on the garbage recovery device embodiment one of virtual machine, wherein, The heap space of the virtual machine includes being deposited less than the Cenozoic of the object of predetermined period for storing activity periods Storage area, the memory block of new generation includes empty for storing the first storage of the new object of application program establishment Between, for preserving the second memory space for enlivening object survived during last garbage reclamation and reserved 3rd memory space, as shown in figure 4, the device includes:
Determining module 401, for it is determined that the new object that the application program is created is stored described first After space is filled with, will be all in the first memory space described in current time and second memory space Enliven object to store into the 3rd memory space;
Module 402 is emptied, for it is determined that all enliven after object stores the 3rd memory space, Empty first memory space and second memory space;
Processing module 403, for according to it is described it is all enliven object shared by memory space size, weight The size of second memory space and the size of the 3rd memory space are put, and is deposited to described second Storage space and the 3rd memory space swap process.
The device that the present embodiment is provided, can be used to perform the technical scheme of said method embodiment, its realization Principle is similar with technique effect, and here is omitted for the present embodiment.
Fig. 5 is structural representation of the present invention based on the garbage recovery device embodiment two of virtual machine.This reality Example is applied on the basis of Fig. 4 embodiments, as shown in figure 5, alternatively, the device also includes:Management mould Block 404;
The management module 404, for the processing module 403 according to it is all enliven object shared by Memory space, before resetting the size of the second memory space and the size of the 3rd memory space,
It is determined that the 3rd memory space is filled with, all of object that enlivens all is not stored to the described 3rd During memory space, discharge in first memory space and stored enliven right to the 3rd memory space As shared memory space, and the remaining free memory to first memory space carries out place of contracing Reason, obtains the free memory after processing that contracts;
The object that enlivens not stored to the 3rd memory space is stored into available to the process of contracing In memory space;
Storing empty to the described first storage it is determined that not storing to the object that enlivens of the 3rd memory space Between after, empty in second memory space and first memory space except it is described contract process after can With the memory space outside memory space.
Alternatively, also include:Operation module 405;
The operation module 405 is used for by first memory space and second memory space Enliven before object stored into the 3rd memory space, suspend the execution of the application program Journey;
The operation module 405 is additionally operable in the remaining space using the heap space as described first After memory space, start the implementation procedure of the application program.
Alternatively, the processing module 403 be additionally operable to according to it is described it is all enliven object shared by storage Space, after resetting the size of the second memory space and the size of the 3rd memory space, will Residue in the memory block of new generation in addition to second memory space with the 3rd memory space is deposited Storage space is used as first memory space.
The device that the present embodiment is provided, can be used to perform the technical scheme of said method embodiment, its realization Principle is similar with technique effect, and here is omitted for the present embodiment.
One of ordinary skill in the art will appreciate that:Realize all or part of step of above-mentioned each method embodiment Suddenly can be completed by the related hardware of programmed instruction.Aforesaid program can be stored in a computer can In reading storage medium.The program upon execution, performs the step of including above-mentioned each method embodiment;And Aforesaid storage medium includes:ROM, RAM, magnetic disc or CD etc. are various can be with store program codes Medium.
Finally it should be noted that:Various embodiments above is only illustrating technical scheme rather than right Its restriction;Although being described in detail to the present invention with reference to foregoing embodiments, this area it is common Technical staff should be understood:It still can modify to the technical scheme described in foregoing embodiments, Either equivalent is carried out to which part or all technical characteristic;And these modifications or replacement, and The scope of the essence disengaging various embodiments of the present invention technical scheme of appropriate technical solution is not made.

Claims (10)

1. a kind of rubbish recovering method based on virtual machine, it is characterised in that the heap space of virtual machine includes For storing of new generation memory block of the activity periods less than the object of predetermined period, the memory block of new generation Including for storing the first memory space of the new object of application program establishment, for preserving last rubbish The second memory space for enlivening object survived during recovery and the 3rd reserved memory space, methods described Including:
After it is determined that the new object that the application program is created is filled with first memory space, will be current All in first memory space described in moment and second memory space enliven object and store to described In 3rd memory space;
It is determined that all enliven after object stores the 3rd memory space, first storage is emptied Space and second memory space;
According to it is described it is all enliven object shared by memory space size, reset second memory space Size and the 3rd memory space size, and to second memory space and the described 3rd Memory space swaps process.
2. method according to claim 1, it is characterised in that enliven object according to all described Shared memory space, reset second memory space size and the 3rd memory space it is big Before little, also include:
It is determined that the 3rd memory space is filled with, all of object that enlivens all is not stored to the described 3rd During memory space, discharge in first memory space and stored enliven right to the 3rd memory space As shared memory space, and the remaining free memory to first memory space carries out place of contracing Reason, obtains the free memory after processing that contracts;
The object that enlivens not stored to the 3rd memory space is stored into available to the process of contracing In memory space;
Storing empty to the described first storage it is determined that not storing to the object that enlivens of the 3rd memory space Between after, empty in second memory space and first memory space except it is described contract process after can With the memory space outside memory space.
3. method according to claim 1 and 2, it is characterised in that the described first storage is empty Between and second memory space in enliven before object stored into the 3rd memory space, also Including:
Suspend the implementation procedure of the application program;
In the remaining space using the heap space as after first memory space, also include:
Start the implementation procedure of the application program.
4. method according to claim 3, it is characterised in that all enlivening object according to described Shared memory space, reset second memory space size and the 3rd memory space it is big After little, also include:
By in the memory block of new generation in addition to second memory space with the 3rd memory space Residual memory space is used as first memory space.
5. method according to claim 3, it is characterised in that the first storage after the replacement is empty Between size with reset after the second memory space size with all memory spaces enlivened shared by object Size it is identical.
6. method according to claim 3, it is characterised in that the heap space of the virtual machine is also wrapped Include:For storing old age of the activity periods more than the object of the predetermined period for memory block.
7. a kind of garbage recovery device based on virtual machine, it is characterised in that the heap space of the virtual machine Including for storing of new generation memory block of the activity periods less than the object of predetermined period, the Cenozoic deposits Storage area is included for storing the first memory space of the new object of application program establishment, for preserving the last time The second memory space for enlivening object survived during garbage reclamation and the 3rd reserved memory space, it is described Device includes:
Determining module, for it is determined that the new object that creates of the application program is by first memory space After being filled with, will be all active in the first memory space described in current time and second memory space Object is stored into the 3rd memory space;
Module is emptied, for it is determined that all enliven after object stores the 3rd memory space, clearly Empty first memory space and second memory space;
Processing module, for according to it is described it is all enliven object shared by memory space size, reset institute The size of the second memory space and the size of the 3rd memory space are stated, and it is empty to the described second storage Between and the 3rd memory space swap process.
8. device according to claim 7, it is characterised in that also include:Management module;
The management module, for the processing module according to it is all enliven object shared by memory space, Before resetting the size of second memory space and the size of the 3rd memory space,
It is determined that the 3rd memory space is filled with, all of object that enlivens all is not stored to the described 3rd During memory space, discharge in first memory space and stored enliven right to the 3rd memory space As shared memory space, and the remaining free memory to first memory space carries out place of contracing Reason, obtains the free memory after processing that contracts;
The object that enlivens not stored to the 3rd memory space is stored into available to the process of contracing In memory space;
Storing empty to the described first storage it is determined that not storing to the object that enlivens of the 3rd memory space Between after, empty in second memory space and first memory space except it is described contract process after can With the memory space outside memory space.
9. the device according to claim 7 or 8, it is characterised in that also include:Operation module;
The operation module is used for by the work in first memory space and second memory space Before jump object is stored into the 3rd memory space, suspend the implementation procedure of the application program;
The operation module is additionally operable in the remaining space using the heap space as the described first storage After space, start the implementation procedure of the application program.
10. device according to claim 9, it is characterised in that the processing module is additionally operable to According to it is described it is all enliven object shared by memory space, reset second memory space size and After the size of the 3rd memory space, second memory space will be removed in the memory block of new generation With the residual memory space outside the 3rd memory space as first memory space.
CN201510740849.7A 2015-11-04 2015-11-04 Garbage recycling method and device based on virtual machine Active CN106648882B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510740849.7A CN106648882B (en) 2015-11-04 2015-11-04 Garbage recycling method and device based on virtual machine

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510740849.7A CN106648882B (en) 2015-11-04 2015-11-04 Garbage recycling method and device based on virtual machine

Publications (2)

Publication Number Publication Date
CN106648882A true CN106648882A (en) 2017-05-10
CN106648882B CN106648882B (en) 2020-03-13

Family

ID=58851081

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510740849.7A Active CN106648882B (en) 2015-11-04 2015-11-04 Garbage recycling method and device based on virtual machine

Country Status (1)

Country Link
CN (1) CN106648882B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109117242A (en) * 2017-06-22 2019-01-01 龙芯中科技术有限公司 Virtual machine garbage reclamation tuning method, apparatus, electronic equipment and storage medium
CN109690485A (en) * 2018-08-24 2019-04-26 袁振南 Rubbish recovering method, computer and storage medium based on data structure
CN110543357A (en) * 2018-05-28 2019-12-06 华为技术有限公司 Method, related device and system for managing application program object

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103995741A (en) * 2014-05-29 2014-08-20 无锡商埃曲信息科技有限公司 Rapid collection method for Java virtual machine generational garbage

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103995741A (en) * 2014-05-29 2014-08-20 无锡商埃曲信息科技有限公司 Rapid collection method for Java virtual machine generational garbage

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
DSXWJHF: "JVM 新生代为何需要两个 Survivor 空间?", 《HTTPS://DSXWJHF.ITEYE.COM/BLOG/2201687》 *
SPIDERCOCO: "JVM堆大小的自适应能力", 《HTTPS://BLOG.CSDN.NET/SPIDERCOCO/ARTICLE/DETAILS/84684404》 *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109117242A (en) * 2017-06-22 2019-01-01 龙芯中科技术有限公司 Virtual machine garbage reclamation tuning method, apparatus, electronic equipment and storage medium
CN110543357A (en) * 2018-05-28 2019-12-06 华为技术有限公司 Method, related device and system for managing application program object
CN110543357B (en) * 2018-05-28 2023-01-13 华为云计算技术有限公司 Method, related device and system for managing application program object
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

Also Published As

Publication number Publication date
CN106648882B (en) 2020-03-13

Similar Documents

Publication Publication Date Title
CN103080911B (en) The pre-emptive garbage reclamation of memory block
US6769004B2 (en) Method and system for incremental stack scanning
CN106484323A (en) A kind of loss equalizing method of solid-state storage and system
CN102591807B (en) Processing method for power down and abnormal writing of solid state disc and system
CN103150259B (en) A kind of method for recovering internal storage and device
CN100468336C (en) Priority-based code cache management
US8612493B2 (en) Allocation cache premarking for snap-shot-at-the-beginning concurrent mark-and-sweep collector
CN103186412B (en) Based on the performance optimization method of JVM server
CN106598878A (en) Method for separating cold data and hot data of solid state disk
CN106648882A (en) Garbage recycling method and device based on virtual machine
CN103577336B (en) A kind of stored data processing method and device
CN106354562A (en) Memory cleaning system and memory cleaning method
CN101971146A (en) System and method to improve memory usage in virtual machines running as hypervisor guests
CN109614344A (en) A kind of spatial cache recovery method, device, equipment and storage system
CN106201659A (en) A kind of method of live migration of virtual machine and host
CN101169739A (en) Method of and apparatus for managing memory
US7822938B2 (en) System and method for performing garbage collection based on unmanaged memory allocations
US8255436B2 (en) Per thread garbage collection
CN103593300B (en) Memory allocating and collecting method
CN106201904A (en) Method and device for internal memory garbage reclamation
CN107844432A (en) A kind of method and solid state hard disc of solid state hard disc dynamic garbage reclamation
CN107766125A (en) A kind of delet method of cloud platform virtual machine
CN102270134B (en) Method and device for recycling garbage in Java card
CN104035879A (en) Memory allocation and garbage collection method based on life-period prediction
CN103699435B (en) Load balancing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
CP01 Change in the name or title of a patent holder

Address after: 100095 Building 2, Longxin Industrial Park, Zhongguancun environmental protection technology demonstration park, Haidian District, Beijing

Patentee after: Loongson Zhongke Technology Co.,Ltd.

Address before: 100095 Building 2, Longxin Industrial Park, Zhongguancun environmental protection technology demonstration park, Haidian District, Beijing

Patentee before: LOONGSON TECHNOLOGY Corp.,Ltd.

CP01 Change in the name or title of a patent holder