CN106293939A - A kind of method of dynamic reuse object in internal memory garbage collector - Google Patents
A kind of method of dynamic reuse object in internal memory garbage collector Download PDFInfo
- Publication number
- CN106293939A CN106293939A CN201610638602.9A CN201610638602A CN106293939A CN 106293939 A CN106293939 A CN 106293939A CN 201610638602 A CN201610638602 A CN 201610638602A CN 106293939 A CN106293939 A CN 106293939A
- Authority
- CN
- China
- Prior art keywords
- stack
- distribution
- memory block
- target cache
- cache
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
- G06F9/5016—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
- G06F2009/45583—Memory management, e.g. access or allocation
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 Of A Hierarchy Structure (AREA)
Abstract
The invention provides a kind of method of dynamic reuse object in internal memory garbage collector, in Java Virtual Machine.This method arranges spatial cache to the object reusing value ratio higher, arranges target cache stack for corresponding class, preserves the address of the dead object of the corresponding class that garbage collector is put into.When object is reused in distribution, find the target cache stack of correspondence according to the metadata of the class reusing object, if target cache stack is not empty, from target cache stack, distribute the same type death object of caching, if target cache stack is empty, distribution object from spatial cache.The address of the dead object of present invention record after object death is reused in distribution, when distribution is with the object of type, directly reuses the space of those dead objects.The present invention can reduce the load of garbage collector distribution object, accelerates the speed of distribution object, the administration overhead on the frequency of minimizing garbage reclamation and internal memory, improves service efficiency and the overall performance of virtual machine of internal memory.
Description
Technical field
The invention belongs to Computer Applied Technology field, specifically a kind of dynamic reuse object in internal memory garbage collector
Method.
Background technology
The most many programming language such as Java, C#, Python and PHP etc., support refuse collection (Garbage
Collectoion, GC), it is used for reclaiming useless internal memory, the most especially with Java Virtual Machine as representative.Garbage collector helper
Member automatically reclaims useless internal memory, it is to avoid incident EMS memory error in many conventional programming language, but garbage collector needs
The operation time of program to be taken, find out death object, then recycle, this for frequent distribution object program very
Unfavorable, too increase the memory management expense (time and space) of garbage collector, since it is desired that shut down procedure frequently simultaneously
So as recovery internal memory.
Summary of the invention
The present invention is directed to the problems referred to above, the method proposing the dynamic reuse Java object of a kind of innovation, can weigh efficiently
With the shortest object of life cycle during those quantity allotted Datong District, it is to avoid these objects are reclaimed by garbage collector, thus
Administration overhead on the frequency of minimizing garbage reclamation and internal memory, improves service efficiency and the globality of virtual machine of internal memory
Energy.
A kind of method of dynamic reuse object in internal memory garbage collector that the present invention provides, real by following aspect
Existing:
(1) organizational form of spatial cache is set;Memory block is organized by spatial cache with a chained list.Spatial cache
Metadata comprise two field: cur_chunk and lock;Cur_chunk points to the head node of chained list, and lock is used for line synchro
The journey access to same spatial cache.Memory block is used for distribution object, and the start-up portion of each memory block deposits memory block
Metadata, comprises three fields: size, free_ptr and next_chunk.Total size of stored memory block in field size,
Free_ptr is free pointer, represents original position during distribution object in this memory block next time, and next_chunk is for referring to
Pointer to next memory block.Memory block in spatial cache never discharges, until just returning to behaviour when virtual machine is destroyed
Make system.
(2) the costly class of reusing for selecting arranges target cache stack, deposits sensing object and delay in the metadata of class
Deposit the pointer of stack, target cache stack saves the address of the dead object of the corresponding class that garbage collector is put into.
(3) when object is reused in distribution, the target cache stack of correspondence is found according to the metadata of the class reusing object, if right
As caching stack is not empty, from target cache stack, distribute the same type death object of caching, if target cache stack is empty, from caching
Distribution object in space.
Advantages of the present invention with have the active effect that this method to those reuse the higher object of value ratio arrange caching sky
Between, the address of the dead object of record after these object death.When distribution is with the object of type, directly reuse those dead
The space of object.This method can reduce the load of garbage collector distribution object, accelerates the speed of distribution object, reduces rubbish and returns
Administration overhead on the frequency received and internal memory, improves service efficiency and the overall performance of virtual machine of internal memory.
Accompanying drawing explanation
Fig. 1 is the object reference view before garbage reclamation occurs;
Fig. 2 is the schematic diagram that survival object is marked by garbage collector;
Fig. 3 is the schematic diagram that dead object carries out recovery stage;
Fig. 4 is the schematic diagram after the object of one type-A of distribution;
Fig. 5 is the organizational structure schematic diagram of spatial cache used in the present invention;
Fig. 6 is metadata and the target cache stack thereof of class;
Fig. 7 is the allocation flow after normal subjects allocation flow and optimization;
Fig. 8 is respectively from caching stack and the flow process of spatial cache distribution object.
Detailed description of the invention
Below in conjunction with drawings and Examples, the present invention is described in further detail.
As it is shown in figure 1, be object distribution in GC (Garbage Collection) heap and spatial cache.Between object
Adduction relationship indicated by an arrow, arrow end represents the object being cited, dotted arrow represent the object at arrow two ends not with
One region, i.e. one at GC heap, one in spatial cache, all survival objects can be arrived by root collection.Garbage collector is not
Can reclaim spatial cache, internal memory therein will carry out effective use according to the inventive method.The knot of tissue of spatial cache
Structure is as shown in Figure 5.
As in figure 2 it is shown, be the marking phase of garbage collector.The top of figure is the distribution situation of object before labelling, figure
Bottom is the distribution situation of object after labelling, and all objects that can not be arrived by root collection are all marked as dead object.This stage
Identify all survival objects, the most any further adduction relationship between dead object and survival object.
As it is shown on figure 3, be the stage reclaiming dead object.In this stage, if a dead object belongs to GC heap, then by
Garbage collector processes according to normal flow, if a dead object belongs to spatial cache, utilizes the inventive method, by this object
Putting in the target cache stack of class type belonging to it, target cache stack is as shown in Figure 6.
As shown in Figure 4, be one type of distribution be the process occurred during the object of A.If this distributing point is through optimizing
Distributing point, then can trigger assigning process as shown in Figure 8.
As it is shown in figure 5, be the organizational structure of spatial cache.One spatial cache is mainly made up of two parts: one is pipe
The metadata that reason spatial cache itself is required, as shown in Fig. 5 upper left side, two is one or more internal memories for distribution object
Block, referred to as Chunk.The metadata of spatial cache comprises two fields, is described as follows:
1) cur_chunk, points to current memory block, and multiple memory blocks are organized by spatial cache with a chained list,
Cur_chunk will point to the head node of this chained list, the most always distributes from current memory block during distribution object the most every time.
2) lock, for synchronizing the access to same spatial cache of multiple thread.
Additionally, the start-up portion of each memory block deposits the metadata of this memory block, comprise three fields, describe such as
Under:
1) size, stores total size of this memory block, and unit is byte;
2) free_ptr, free pointer represents original position during distribution object in this memory block next time;
3) next_chunk, points to the pointer of next memory block, for being linked by all of memory block in spatial cache
Together.
In Fig. 5, Chunk A and Chunk B is two memory blocks, and Chunk A is current memory block, and the end of Chunk B has
A part of internal memory does not dispense, and reason is that this section of remaining free memory is the least, it is impossible to meet the distribution requirement of object.Often
Secondary from spatial cache during distribution object, from current memory block cur_chunk, always obtain internal memory.Internal memory in spatial cache
Block never discharges, until just returning to operating system when virtual machine is destroyed.
As shown in Figure 6, for metadata structure and the relation of target cache stack of class class.In each java applet
Class has a data structure as shown in Figure 6 to represent it at virtual machine internal, and the referred to as metadata of class, it houses this
The information such as the method for class, field, parent, interface function.Costly class of reusing for selecting arranges target cache stack.At Fig. 6
In, the caching stack pointer cache_stack in the metadata structure of class points to target cache stack C_stack, in target cache stack
Save the address of the dead object that type is X that garbage collector is put into.Target cache stack can also use other data structure
Realize, such as queue, but be that its characteristic that last in, first out means that the object of distribution is recovered the most recently by the benefit of stack, can
Increase the cache hit rate of CPU.
As it is shown in fig. 7, be the object allocation flow after normal object allocation flow and optimization.The dotted box portion on top
For the flow process of normal distribution object, the solid box of bottom is the object allocation flow after optimizing.In distribution, those reuse value
During high object, needing the distributing point to distributing these objects to carry out special handling, the machine code of generation will be called
CacheAlloc function carries out the distribution of object, and the execution step of this function is as follows:
Step one, obtains the pointer cache_stack in the class metadata structure of object.
Step 2, according to class pointer cache_stack, obtains the target cache stack C_stack of the type;
Step 3, if target cache stack C_stack is not empty, then carries out object according to flow process shown in Fig. 8 left-hand broken line and divides
Join, the same type death object of caching will be distributed from target cache stack C_stack.If target cache stack C_stack is empty, will
Distribution object from spatial cache, forwards step 4 to and performs.
Step 4, according to right side bold portion, distribution object from spatial cache in Fig. 8.
As shown in Figure 8, respectively show from target cache stack C_stack and the flow process of spatial cache distribution object, be right
The continued access of Fig. 7.Left-hand broken line is the part taking stack top element from target cache stack C_stack.Need to be through following steps:
The first step, obtains the lock of target cache stack C_stack;
Second step, preserves stack top element to zero variations per hour obj, then ejects stack top element;
Obj=C_stack.pop ();
3rd step, the lock of releasing object caching stack C_stack;
4th step, returns obj.Obj is the address of selected dead object, i.e. the address of object is reused in distribution.
Such as, the change that comparison Fig. 3 to Fig. 4 occurs, when distribution type is the object of A, due to corresponding target cache stack
C_stack is not empty, the most directly takes stack top element, and the memory headroom that before having reused, object takies is kept away simultaneously
Exempt from and garbage collector is mutual.
Right side solid line is that distribution object need to be through following steps from spatial cache:
1st step, obtains spatial cache lock;
2nd step, if the free memory of current memory block meets object size in spatial cache, the most first by current memory block
Free_ptr value gives temporary variable obj, then allows free_ptr increase size obj_size of object;If current memory block
Free memory is less than object size, then forward the 5th step to;
3rd step, release spatial cache lock;
4th step, returning obj, obj is the address that object is reused in distribution;
5th step, to one new memory block of operating system application, using this memory block as current memory block, and updates
The value of cur_chunk and free_ptr, forwards the 2nd step to.
The innovative point of the present invention essentially consists in and is provided with spatial cache, reuses dead object, and selected is reused value height
Object use said method of the present invention be optimized distribution.Reuse costly object and refer to that a large amount of distribution are the biggest in a program
Some objects that amount is dead.
Claims (4)
1. the method for dynamic reuse object in internal memory garbage collector, it is characterised in that realized by following aspect:
(1) organizational form of spatial cache is set;Memory block is organized by spatial cache with a chained list.The unit of spatial cache
Packet contains two field: cur_chunk and lock;Cur_chunk points to the head node of chained list, and lock is used for synchronizing thread pair
The access of same spatial cache;Memory block is used for distribution object, and the start-up portion of each memory block deposits first number of memory block
According to, comprise three fields: size, free_ptr and next_chunk;Total size of stored memory block, free_ in field size
Ptr is free pointer, represents original position during distribution object in this memory block next time, and next_chunk is for pointing to next
The pointer of individual memory block;Memory block in spatial cache never discharges, until just returning to operating system when virtual machine is destroyed;
(2) the costly class of reusing for selecting all arranges target cache stack, deposits sensing target cache in the metadata of class
The pointer of stack, preserves the address of the dead object of the corresponding class that garbage collector is put in target cache stack;
(3) when object is reused in distribution, the target cache stack of correspondence is found according to the metadata of the class reusing object, if object delays
Deposit stack not for empty, from target cache stack, distribute the same type death object of caching, if target cache stack is empty, from spatial cache
Middle distribution object.
A kind of method of dynamic reuse object in internal memory garbage collector the most according to claim 1, it is characterised in that
The described same type death object distributing caching from target cache stack, specifically:
The first step, obtains the lock of target cache stack;
Second step, preserves stack top element to zero variations per hour obj, then ejects stack top element;
3rd step, the lock of releasing object caching stack;
4th step, returning obj, obj is the address that object is reused in distribution.
A kind of method of dynamic reuse object in internal memory garbage collector the most according to claim 1, it is characterised in that
Described distribution object from spatial cache, specifically:
1st step, obtains the lock of spatial cache;
2nd step, if the free memory of current memory block meets object size in spatial cache, the most first by current memory block
Free_ptr value gives temporary variable obj, then allows free_ptr increase the size of object;If the free memory of current memory block
Less than object size, then forward the 5th step to;
3rd step, release spatial cache lock;
4th step, returning obj, obj is the address that object is reused in distribution;
5th step, to one new memory block of operating system application, using this memory block as current memory block, and updates cur_
The value of chunk and free_ptr, forwards the 2nd step to and performs.
A kind of method of dynamic reuse object in internal memory garbage collector the most according to claim 1, it is characterised in that
Described target cache stack, it is also possible to replace with queue, to preserve the dead object of the corresponding class that garbage collector is put into
Address.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610638602.9A CN106293939B (en) | 2016-08-05 | 2016-08-05 | A method of the dynamic reuse object in memory garbage collector |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610638602.9A CN106293939B (en) | 2016-08-05 | 2016-08-05 | A method of the dynamic reuse object in memory garbage collector |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106293939A true CN106293939A (en) | 2017-01-04 |
CN106293939B CN106293939B (en) | 2019-10-18 |
Family
ID=57665655
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610638602.9A Active CN106293939B (en) | 2016-08-05 | 2016-08-05 | A method of the dynamic reuse object in memory garbage collector |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106293939B (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109857814A (en) * | 2018-12-28 | 2019-06-07 | 北京东方国信科技股份有限公司 | A kind of internal storage data processing method and storage medium |
WO2019184776A1 (en) * | 2018-03-27 | 2019-10-03 | 阿里巴巴集团控股有限公司 | Data caching method and device |
CN116860658A (en) * | 2023-06-21 | 2023-10-10 | 中国科学院软件研究所 | Efficient semi-automatic garbage collection method and system for big data processing frame |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20020161894A1 (en) * | 2001-04-27 | 2002-10-31 | International Business Machines Corporation | Mechanism to cache references to Java RMI remote objects implementing the unreferenced interface |
CN1604051A (en) * | 2003-09-30 | 2005-04-06 | 三星电子株式会社 | Method and apparatus for dynamic memory management within an object-oriented program |
US7263700B1 (en) * | 2000-11-06 | 2007-08-28 | International Business Machines Corporation | Serially, reusable virtual machine |
CN101046755A (en) * | 2006-03-28 | 2007-10-03 | 郭明南 | System and method of computer automatic memory management |
CN101169759A (en) * | 2007-11-08 | 2008-04-30 | Ut斯达康通讯有限公司 | Memory management method for application program |
CN102023891A (en) * | 2010-12-20 | 2011-04-20 | 复旦大学 | Concurrent garbage collector frame based on Java virtual machine |
CN102722447A (en) * | 2012-06-06 | 2012-10-10 | 北京航空航天大学 | Incremental track record method of object state in memory garbage collector |
-
2016
- 2016-08-05 CN CN201610638602.9A patent/CN106293939B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7263700B1 (en) * | 2000-11-06 | 2007-08-28 | International Business Machines Corporation | Serially, reusable virtual machine |
US20020161894A1 (en) * | 2001-04-27 | 2002-10-31 | International Business Machines Corporation | Mechanism to cache references to Java RMI remote objects implementing the unreferenced interface |
CN1604051A (en) * | 2003-09-30 | 2005-04-06 | 三星电子株式会社 | Method and apparatus for dynamic memory management within an object-oriented program |
CN101046755A (en) * | 2006-03-28 | 2007-10-03 | 郭明南 | System and method of computer automatic memory management |
CN101169759A (en) * | 2007-11-08 | 2008-04-30 | Ut斯达康通讯有限公司 | Memory management method for application program |
CN102023891A (en) * | 2010-12-20 | 2011-04-20 | 复旦大学 | Concurrent garbage collector frame based on Java virtual machine |
CN102722447A (en) * | 2012-06-06 | 2012-10-10 | 北京航空航天大学 | Incremental track record method of object state in memory garbage collector |
Non-Patent Citations (1)
Title |
---|
陈贤闯 等: "一种基于栈式分配的JVM垃圾收集算法", 《计算机系统应用》 * |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2019184776A1 (en) * | 2018-03-27 | 2019-10-03 | 阿里巴巴集团控股有限公司 | Data caching method and device |
CN110309079A (en) * | 2018-03-27 | 2019-10-08 | 阿里巴巴集团控股有限公司 | A kind of method and device of data buffer storage |
CN109857814A (en) * | 2018-12-28 | 2019-06-07 | 北京东方国信科技股份有限公司 | A kind of internal storage data processing method and storage medium |
CN116860658A (en) * | 2023-06-21 | 2023-10-10 | 中国科学院软件研究所 | Efficient semi-automatic garbage collection method and system for big data processing frame |
CN116860658B (en) * | 2023-06-21 | 2024-05-28 | 中国科学院软件研究所 | Efficient semi-automatic garbage collection method and system for big data processing frame |
Also Published As
Publication number | Publication date |
---|---|
CN106293939B (en) | 2019-10-18 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US6105040A (en) | Method and apparatus for managing stored objects | |
US7310718B1 (en) | Method for enabling comprehensive profiling of garbage-collected memory systems | |
CN1321377C (en) | Method for controlling smart card storage environment | |
CN101692252B (en) | Method for distributing and reclaiming idle blocks of file | |
CN103365788B (en) | The adaptive local rubbish recovering method that real-time flash memory conversion layer uses | |
CN104731799B (en) | Main memory DBM device | |
CN106293939A (en) | A kind of method of dynamic reuse object in internal memory garbage collector | |
WO2013192020A1 (en) | Memory compaction mechanism for main memory databases | |
US10628304B2 (en) | Garbage collection in an in-memory replication system | |
CN105718319B (en) | Memory pool layout analysis method and memory pool device | |
CN103593300B (en) | Memory allocating and collecting method | |
CN101968772A (en) | Method for implementing efficient memory pool of embedded system | |
CN103455433A (en) | Memory management method and system | |
CN102694878B (en) | Sectional ID (Identity) distributing method | |
US8447793B2 (en) | Efficient remembered set for region-based garbage collectors | |
US10216627B1 (en) | Tree structure serialization and deserialization systems and methods | |
CN104572871A (en) | Method and device for searching based on index table | |
CN103699681B (en) | The treating method and apparatus of data rewind | |
Tavakolisomeh | Selecting a JVM garbage collector for big data and cloud services | |
CN100382047C (en) | Method for garbage collection of unused methods | |
CN107800806B (en) | Storage resource recovery method, shared memory systems and cloud service system under cloud environment | |
CN104932982B (en) | A kind of Compilation Method and relevant apparatus of message memory access | |
CN103488576A (en) | Method for managing small high-performance memory blocks | |
CN106648882A (en) | Garbage recycling method and device based on virtual machine | |
CN102541654A (en) | Efficient memory management method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |