Avoid collecting young gen while doing the full GC

Tony Printezis tony.printezis at sun.com
Tue Mar 23 19:44:41 UTC 2010


You also have to make sure that the card table (the data structure that 
keeps track of old-to-young refs) is left consistent at the end of the 
GCs. So, as you move old objects that point to the young gen, you might 
have to update the card table accordingly. An easy way to do that (good 
to at least make sure that the rest of the implementation is working 
correctly) is to dirty the cards of the entire old gen. This will make 
the next young GCs really slow, but the young collector should deal with 
it correctly and clean up the card table as necessary.

I'm also curious why you want to do this. My wild guess would be that 
you're maybe using a huge young gen, relatively to the old gen, and as a 
result it's better to let the young collector deal with it rather than 
compacting it (which would be much slower).


Y. Srinivas Ramakrishna wrote:
> Hi Tony --
> On 03/23/10 10:57, Tony Guan wrote:
>> Hi all,
>> In my current project, one crazy idea is to leave the young generation
>> untouched(not collected) during a Full Gc. Is it feasible if I want to
>> collect the tenured gen only in a full GC?
>> To do this, the young gen should be included as part of the root set,
>> and the reference processor should only care about the old gen. Is
>> there anything else I should take care of?
> Yes, i believe that should work. (In fact, the CMS collector, which 
> collects
> only the old gen and perm gen, does pretty much that. There are some 
> disadvantages
> to it though, for example, dead objects in the young gen possibly keeping
> objects in old and perm gen artificially alive, but such cases are 
> probably
> rare.)
> Just out of curiosity, when and wny would you want to not collect the 
> young gen?
> -- ramki
>> Thanks!
>> Tony

More information about the hotspot-gc-dev mailing list