Collection of DefNewGeneration

Jon Masamitsu jon.masamitsu at oracle.com
Mon Aug 10 03:03:06 UTC 2015


Look at the code in GenCollectedHeap::gen_process_roots()

  704     older_gens->set_generation(_old_gen);
  705     rem_set()->younger_refs_iterate(_old_gen, older_gens, 
scope->n_threads(     ));
  706     older_gens->reset_generation();

The defNew collect() copies live objects that it finds in the defNew 
(young) generation.
For objects in the young gen that are pointed to from the old 
generation, collect()
uses a remembered set (in the form of a card table).  The card table 
tells the defNew
collect() where to look for objects in the young generation referenced 
from the old
generation.

Jon

On 8/8/2015 9:50 AM, Abhinav Jangda wrote:
> Hello everyone,
>
> I was trying to understand how serial generational gc works in 
> Hotspot. I was able to understand how TenuredGeneration is marked 
> using different OopClosures. I can see how beautifully the concept of 
> Visitor Design Pattern has been used.
> But I am having a slight difficulty in understanding how 
> DefNewGeneration works.
> I do understand that DefNewGeneration::collect method is called which 
> then calls GenCollectedHeap::gen_process_strong_roots. This is same as 
> the TenuredGeneration::collect calls 
> GenCollectedHeap::gen_process_strong_roots but in both of these cases 
> the OopClosure are different. In TenuredGeneration::collect, 
> FollowRootClosure (There are 3 closures but let us focus on only one 
> of them) is used and in DefNewGeneration::collect, FastScanClosure is 
> used. Well, the problem starts here.
> In FollowRootClosure::do_oop method, the oop to be traversed is pushed 
> on the marking stack which then is able to follow the contents of this 
> oop. In FastScanClosure there is no such thing. In 
> FastScanClosure::do_oop_work method, the oop is first checked whether 
> it is in this generation and only if it is then oop is transferred to 
> another space/generation. oop's fields are not traversed like they are 
> in FollowRootClosure. Let us suppose the root object is not in the 
> DefNewGeneration but its fields are. So, in this case the fields 
> wouldn't be traversed?
> How, the fields of root objects are traversed in the case of 
> FastScanClosure? If they are traversed by some other way and 
> FastScanClosure use the result of it, then please tell me that.
> Please help me, a small function name or hint should be enough for me.
>
> Thank You,
>
> Abhinav

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/hotspot-gc-dev/attachments/20150809/e8381adc/attachment.htm>


More information about the hotspot-gc-dev mailing list