Thursday 28 January 2021

Java9: Additional tests for humongous objects in G1

G1 stands for Garbage first collector. G1 Collector partitions entire heap into set of equal sized regions. Some regions are given to Eden space, some are given to survival space and some are given to old generation.

 

 


G1 performs a concurrent global marking phase to determine the liveness of objects throughout the heap. After the mark phase completes, G1 knows which regions are mostly empty. It collects in these regions first, which usually yields a large amount of free space. G1 concentrates its collection and compaction activity on the areas of the heap that are likely to be full of reclaimable objects, that is, garbage. G1 uses a pause prediction model to meet a user-defined pause time target and selects the number of regions to collect based on the specified pause time target.

 

Humongous Object

If any object size is bigger than one-half of a memory region, called humongous objects.

a.   If a humongous object is smaller than one region then it takes up the whole region. If a humongous object is larger than N regions and smaller than (N+1) regions then it takes up (N+1) regions. No allocations are allowed in free space.

b.   Humongous objects can be collected at the end of concurrent marking cycle, during a full GC or in young GC in case of G1 Eager Reclaim.

c.    Humongous objects can't be moved from one region to other region.

 

Whitebox Testing API

WhiteBox testing API is a tool in HotSpot VM and is introduced in Java7. It is used to query HotSpot internals. As part of this feature, WhiteBox API is extended and implement Java tests that use to check G1's internal state. Newly developed Whitebox APIs can be used to perform stress tests too.

 

Whitebox API is extended with following features.

 

a.   Methods to block and initiate concurrent marking and full GCs.

b.   Methods to enumerate G1's regions and access region attributes (e.g., free/occupied/humongous).

c.    Methods to access internal G1 variables such as free memory, region size, and the number of free regions.

d.   Methods to locate regions in the heap, to check that no allocations happen in regions that belong to humongous objects. (This could potentially be a first step to a "heap walker" API that allows us to fully iterate over the Java heap).

 

Reference

https://openjdk.java.net/jeps/278

https://wiki.openjdk.java.net/display/HotSpot/The+WhiteBox+testing+API


Previous                                                    Next                                                    Home

No comments:

Post a Comment