CN103995741A - Rapid collection method for Java virtual machine generational garbage - Google Patents

Rapid collection method for Java virtual machine generational garbage Download PDF

Info

Publication number
CN103995741A
CN103995741A CN201410236367.3A CN201410236367A CN103995741A CN 103995741 A CN103995741 A CN 103995741A CN 201410236367 A CN201410236367 A CN 201410236367A CN 103995741 A CN103995741 A CN 103995741A
Authority
CN
China
Prior art keywords
memory
internal memory
collection
virtual machine
java virtual
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.)
Pending
Application number
CN201410236367.3A
Other languages
Chinese (zh)
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.)
WUXI SHANGAIQU INFORMATION TECHNOLOGY Co Ltd
Original Assignee
WUXI SHANGAIQU INFORMATION TECHNOLOGY 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 WUXI SHANGAIQU INFORMATION TECHNOLOGY Co Ltd filed Critical WUXI SHANGAIQU INFORMATION TECHNOLOGY Co Ltd
Priority to CN201410236367.3A priority Critical patent/CN103995741A/en
Publication of CN103995741A publication Critical patent/CN103995741A/en
Pending legal-status Critical Current

Links

Abstract

The invention discloses a rapid collection method for Java virtual machine generational garbage. A virtual table is adopted to build a garbage collector for collecting and managing the memory space. A memory is divided into a plurality of memory blocks equal in size. The memory blocks belong to different memory sets. Each memory set comprises a plurality of memory blocks. As for the memory sets waiting for being collected and treated inside the memory space, the memory blocks inside each memory set are scanned respectively. The memory sets are ranked in sequence, the prior memory sets are scanned and collected, then the posterior memory sets are scanned and collected, and it is similar to replacement between generations. If all objects in the memory blocks inside a certain memory set J are not referenced by the memory blocks inside the other memory sets, the memory set J is the garbage memory and is collected. According to the rapid collection method, due to the characteristics that hardware arithmetic capability of a set top box is not high, the memory is limited, and the real-time performance is not high, the arithmetic speed is improved, the response time is shortened, and the requirement for the real-time performance of the digital television set top box is well met.

Description

A kind of Java Virtual Machine divides for rubbish fastly recovering
Technical field
The invention belongs to digital TV middleware field, particularly a kind of Java Virtual Machine divides for rubbish fastly recovering.
Background technology
The business that digital TV middleware is radio and TV operator provides a relatively uniform platform, makes cross-domain business intercommunication become simpler.Abstract by bottom hardware resource of middleware Technology, support to the various application in upper strata is provided, its middleware platform is responsible for shielding bottom hardware otherness, and is that upper strata api interface calls for third party's business module by underlying resource module abstracts, by terminal platform, is resolved and is presented.In middleware platform, terminal platform, when being responsible for basic audio frequency and video and playing, is also responsible for the application of receiving front-end broadcast, and is moved these application according to user's operation, makes cross-platform, carrying out of magnanimity information business become possibility.
For digital TV middleware software platform, China Digital TV middleware standard has been stipulated essential support Java application.Realize the function of supporting Java, conventionally comprise a Java Virtual Machine, be used for carrying out and operate in the java application in digital TV set-top box, by unique structure and cross-platform design, by application program and middleware standard, underlying operating system, hardware driving are kept apart, and make the service application of the Digital Television on upper strata needn't consider too much platform details, realize cross-platform and hardware independence.
Under digital TV middleware framework, Java Virtual Machine adopts compact object topological design, and the pattern of unified resource management makes memory mapping compact as far as possible, in order to guarantee the travelling speed of system.In Java Virtual Machine, not only want distribution object memory source used, also need the service condition of tracking assets, make regular check on out the internal memory not re-using, by system the automatic recovery and do sub-distribution again, this is called as garbage reclamation mechanism.In this manner, java applet must be considered internal memory release And Spread of Solute, has affected the requirement of real-time of Set Top Box.
Summary of the invention
The object of this invention is to provide a kind of Java Virtual Machine and divide for rubbish fastly recovering, make need not consider in java applet the release And Spread of Solute of internal memory, for improving the security of system program, meet the requirement of real-time of Set Top Box.
Technical scheme of the present invention is that a kind of Java Virtual Machine divides for rubbish fastly recovering, comprises step:
Adopt Virtual table to build for reclaiming and arrange the Garbage Collector of memory headroom;
Internal memory is divided into a plurality of equal-sized memory blocks, and each memory block belongs to different internal memory collection, and internal memory collection is the set that comprises some memory blocks;
For wait, be recovered a plurality of internal memory collection in the memory headroom of processing, scan respectively the memory block in each internal memory collection;
Internal memory collection is according to sequencing, and internal memory collection formerly is first scanned and can reclaims, after internal memory collection after be scanned recovery, as generation-inter-, substitute;
If the object in the memory block in certain internal memory collection J is not all by the object reference in the memory block in other internal memory collection, this internal memory integrates J as rubbish internal memory, is recovered.
Also comprise step:
If the object A in the memory block of certain internal memory collection J is quoted by object B in the memory block C of other internal memory collection, by object A and being transferred in memory block C with exist together other objects of internal memory collection J of object A of having an adduction relationship with object A;
If memory block C is full, at the afterbody of the residing internal memory collection of memory block, opens up new memory block and once deposit.
Also comprise step:
The object of not quoted by other internal memory collection in internal memory collection J is transferred to the afterbody of internal memory collection J, when being scanned up to internal memory collection J afterbody, the described object that is transferred to internal memory collection J afterbody is not still in the external object of other internal memory collection to be quoted, and internal memory collection J is recovered.
Described Java Virtual Machine divides for rubbish and reclaims fast, also comprises the system resource of I/0 and semaphore is reclaimed.
Java Virtual Machine of the prior art has adopted train algorithm, and its strategy that at every turn only reclaims a train number makes the working time of Java Virtual Machine garbage reclamation in controlled range, but can not guarantee when garbage reclamation is moved.And according to test, under digital TV middleware framework, Java Virtual Machine moves still less occupying system resources of garbage reclamation under low loading condition, therefore consider that optimizing current Garbage Collector adopts train algorithm.
The strategy of concrete employing of the present invention is roughly as follows: under digital TV middleware framework, at Java Virtual Machine, adopt compact object topological design, the pattern of unified resource management, make memory mapping compact as far as possible, not only want distribution object memory source used, also need the service condition of tracking assets, make regular check on out the internal memory not re-using, by system the automatic recovery and do sub-distribution again, this is called as garbage reclamation mechanism.System resource of inner establishment is used information table, this table record the situation of calling of system resource and correlation technique, by the statistics and analysis to system resource information table, adopt asynchronous system notice Garbage Collector to operate in the smaller state of system load, by dividing the train algorithm for garbage reclamation, to only reclaim the strategy of a row train at every turn, the space of Java Virtual Machine garbage reclamation is controlled within the specific limits, thereby meet to a great extent Digital Television real-time demand and reach system load balance as far as possible, elevator system overall performance.
The present invention adopts unique Virtual table technology, improve Java Virtual Machine and divide the fast collecting method for garbage reclamation,, memory limited not high mainly for top-set hardware arithmetic capability, real-time feature, having broken through traditional Java Virtual Machine divides for rubbish recovering method, adopt new design and optimized algorithm, improve arithmetic speed and response time, met well the requirement of real-time of digital TV set-top box.
Accompanying drawing explanation
The Digital Television Java Virtual Machine frame diagram that Fig. 1 the present invention relates to.
Fig. 2 digital TV middleware structural representation of the present invention.
Fig. 3 is one of algorithm schematic diagram in the embodiment of the present invention
Fig. 4 is one of algorithm schematic diagram in the embodiment of the present invention
Fig. 5 is one of algorithm schematic diagram in the embodiment of the present invention
Embodiment
In the realization of Java Virtual Machine, Garbage Collector is in one of center-stage.The quality of Garbage Collector design directly affects Java Virtual Machine execution performance and memory consumption.
The function of Garbage Collector is to reclaim the memory object not re-using, and discontinuous heap fragment is arranged simultaneously.In Set Top Box, move java applet, performance is very important, does not wish that Garbage Collector takies the oversize time in the time of operation java applet, so that allow java applet operation slowly.So can not surpass a maximum time in the time of must guaranteeing Garbage Collector operation.
This invention is through large quantity algorithm and data research, realizes Garbage Collector and adopted train algorithm in Java Virtual Machine.This algorithm adopts gradual collection rubbish, is not once to collect all rubbish, has guaranteed that like this acquisition time can be not oversize.Train algorithm is the progressive collection that limiting time is provided in ripe object space.In train algorithm, internal memory is divided into piece, and a plurality of form a set.For imagery, a joint compartment represents a piece, and a row train represents a set, sees Fig. 3.
Note each compartment equal and opposite in direction, but the compartment number that each train comprises not necessarily equates.Refuse collection be take compartment as unit, and collection is sequentially followed successively by 1.1,1.2,1.3,1.4,2.1,2.2,2.3,3.1,3.2,3.3 ...This order is also the sequencing that piece is created.
As shown in Figure 3, garbage collector first starts scanning until 1.4 from piece 1.1.If all objects in four pieces of train 1 are by the object reference of train 2 and train 3, and only have the object of train 1 inside mutually to quote, whole train 1 is all rubbish, can be recovered.
As shown in Figure 4, in compartment 1.1, there are object A and object B, have object C in 1.3, have object D in 1.4, in compartment 2.2, have object E, in compartment 3.3, have object F.In train 1, object C reference object A, object B reference object D, visible, train 2 and train 3 are not quoted the object of train 1, and whole train 1 is all rubbish.
In train 1, there is object to be quoted by other train, see Fig. 5, scanning finds that object A is quoted by the E in train 2 during compartment 1.1, object A 1.1 is transferred to compartment 2.2 from compartment, the object D that then scan A is quoted, also transfers to compartment 2.2 D, then scan D, see whether D quotes other object, if quoted other object, also will shift, the like.Scanned after all objects of train 1, the remaining object that there is no transfer is all rubbish, can be using whole train 1 all as garbage reclamation.If note, when shifting, if has expired in 2.2 spaces, compartment, will opening up new compartment 2.4 at train 2 ends, the object newly shifting be all put into 2.4, i.e. the afterbody of train)
Supplementary notes: Garbage Collector once only scans a compartment.Object B in Fig. 5 and C are recovered immediately, but first can be transferred to the afterbody compartment of train 1.After having scanned 1.1, B is transferred to train 1 afterbody, and after having scanned 1.3, C is transferred to the tailstock.While scanning train 1 afterbody Deng garbage collector, if still do not have external object to quote them, B and C can be collected.The benefit of train algorithm maximum is that it can guarantee that large loop structure can be collected completely.Because become the object in the loop structure of rubbish, no matter much, all can be moved into same row train, be finally collected together.
After Java Virtual Machine operation, soon, in garbage reclamation process, can run into the system resource that some may not re-use, as internal memory, I/0, semaphore etc.But As time goes on, the life cycle of various resources is different.Some resource can be reclaimed frequently, and some resource can just reclaim for a long time.Based on such a situation, adopt a minute generation to manage the resource that these can be recovered.Due to condition restriction and the real-time of embedded hardware resource, the time of garbage reclamation need to be determined in certain a period of time again, can not be greater than this time, otherwise can affect the performance of whole system.Therefore this just invents the train algorithm that has adopted generational garbage collection.In Java Virtual Machine, in a minute generation, represents with every row train.
Every row train size is fixing, and first row train has represented the callable system resource of the first generation, and secondary series train has represented the recyclable resource of the second generation, by that analogy.The rubbish reclaiming at first is always found in first row train, As time goes on, when the system resource of distributing has taken first row train, we scan each railway carriage of first row train according to this, the resource that can't reclaim is moved in secondary series train, form the second generation.Because the size of first row train is fixed, our train of interscan complete column at the appointed time so, when first row train is complete, I just discharge whole train empty time, and secondary series train just becomes first row like this, and the rest may be inferred.Because the most of resource of generalized case is all the resource reclaiming fast, so this algorithm performance is fine.

Claims (4)

1. Java Virtual Machine divides for a rubbish fastly recovering, it is characterized in that, comprises step:
Adopt Virtual table to build for reclaiming and arrange the Garbage Collector of memory headroom;
Internal memory is divided into a plurality of equal-sized memory blocks, and each memory block belongs to different internal memory collection, and internal memory collection is the set that comprises some memory blocks;
For wait, be recovered a plurality of internal memory collection in the memory headroom of processing, scan respectively the memory block in each internal memory collection;
Internal memory collection is according to sequencing, and internal memory collection formerly is first scanned and can reclaims, after internal memory collection after be scanned recovery, as generation-inter-, substitute;
If the object in the memory block in certain internal memory collection J is not all by the object reference in the memory block in other internal memory collection, this internal memory integrates J as rubbish internal memory, is recovered.
2. Java Virtual Machine as claimed in claim 1 divides for rubbish fastly recovering, it is characterized in that, comprises step:
If the object A in the memory block of certain internal memory collection J is quoted by object B in the memory block C of other internal memory collection, by object A and being transferred in memory block C with exist together other objects of internal memory collection J of object A of having an adduction relationship with object A;
If memory block C is full, at the afterbody of the residing internal memory collection of memory block, opens up new memory block and once deposit.
3. Java Virtual Machine as claimed in claim 2 divides for rubbish fastly recovering, it is characterized in that, comprises step:
The object of not quoted by other internal memory collection in internal memory collection J is transferred to the afterbody of internal memory collection J, when being scanned up to internal memory collection J afterbody, the described object that is transferred to internal memory collection J afterbody is not still in the external object of other internal memory collection to be quoted, and internal memory collection J is recovered.
4. Java Virtual Machine as claimed in claim 1 divides for rubbish fastly recovering, it is characterized in that, described Java Virtual Machine divides for rubbish and reclaims fast, also comprises the system resource of I/0 and semaphore is reclaimed.
CN201410236367.3A 2014-05-29 2014-05-29 Rapid collection method for Java virtual machine generational garbage Pending CN103995741A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410236367.3A CN103995741A (en) 2014-05-29 2014-05-29 Rapid collection method for Java virtual machine generational garbage

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410236367.3A CN103995741A (en) 2014-05-29 2014-05-29 Rapid collection method for Java virtual machine generational garbage

Publications (1)

Publication Number Publication Date
CN103995741A true CN103995741A (en) 2014-08-20

Family

ID=51309915

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410236367.3A Pending CN103995741A (en) 2014-05-29 2014-05-29 Rapid collection method for Java virtual machine generational garbage

Country Status (1)

Country Link
CN (1) CN103995741A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104535000A (en) * 2014-12-18 2015-04-22 陕西科技大学 Leather thickness measuring device based on FBG sensors
CN106648882A (en) * 2015-11-04 2017-05-10 龙芯中科技术有限公司 Garbage recycling method and device based on virtual machine
CN114265670A (en) * 2022-03-02 2022-04-01 阿里云计算有限公司 Memory block sorting method, medium and computing device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060259528A1 (en) * 2005-05-13 2006-11-16 Microsoft Corporation Implementation for collecting unmanaged memory
CN101281458A (en) * 2008-05-14 2008-10-08 华为技术有限公司 Apparatus, system and for recycling rubbish
CN103226476A (en) * 2013-05-20 2013-07-31 张永强 Garbage object detecting method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060259528A1 (en) * 2005-05-13 2006-11-16 Microsoft Corporation Implementation for collecting unmanaged memory
CN101281458A (en) * 2008-05-14 2008-10-08 华为技术有限公司 Apparatus, system and for recycling rubbish
CN103226476A (en) * 2013-05-20 2013-07-31 张永强 Garbage object detecting method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
陈健明: ""嵌入式环境下JVM的研究与实现"", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104535000A (en) * 2014-12-18 2015-04-22 陕西科技大学 Leather thickness measuring device based on FBG sensors
CN106648882A (en) * 2015-11-04 2017-05-10 龙芯中科技术有限公司 Garbage recycling method and device based on virtual machine
CN106648882B (en) * 2015-11-04 2020-03-13 龙芯中科技术有限公司 Garbage recycling method and device based on virtual machine
CN114265670A (en) * 2022-03-02 2022-04-01 阿里云计算有限公司 Memory block sorting method, medium and computing device

Similar Documents

Publication Publication Date Title
CN103853727B (en) Improve the method and system of big data quantity query performance
CN105446814A (en) Cache recovery method and device
CN103412825B (en) A kind of memory release method and device
CN103593298B (en) Method for recovering internal storage and device
CN103631868B (en) Data management system compatible with relational database
CN101944114A (en) Data synchronization method between memory database and physical database
CN102521145A (en) Java card system and space distribution processing method thereof
CN106598878A (en) Method for separating cold data and hot data of solid state disk
CN106657174A (en) Data synchronizing and updating methods and data synchronizing and updating devices
CN106354562A (en) Memory cleaning system and memory cleaning method
CN103995741A (en) Rapid collection method for Java virtual machine generational garbage
CN105159915A (en) Dynamically adaptive LSM (Log-structured merge) tree combination method and system
CN104348862B (en) Data Migration processing method, apparatus and system
CN103177000A (en) Grouping method of Internet protocol (IP) addresses or cell phone numbers and query method of attribution place
CN103995807A (en) Massive data query and secondary processing method based on Web architecture
CN109739818A (en) A kind of portable high-throughput big data acquisition method and system
CN101246440B (en) Java card system rubbish recovering method
CN101656950A (en) Method and mobile terminal for locking cell
CN103678337A (en) Data eliminating method, device and system
CN103092866B (en) Data monitoring method and supervising device
CN105022593B (en) A kind of storage optimization method cooperateed with based on data compression and data de-redundant
CN102831168B (en) A kind of computing method of KPI index and device
CN1665314A (en) Method for prior triggering of multi-service for mobile intelligent network
CN111177021A (en) Java card fragment management method and storage device thereof
CN101466071B (en) Method and apparatus for distributing time frequency resource

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20140820