Java 11 is ready with new exciting features and it have nasty surprises as well, It have a newly designed Garbage Collector which is fast, scalable and easy to tune. Let's find out what is it. It is one of the most exciting feature in JDK 11. This brand new Garbage Collector, ZGC, which is being developed by Oracle that promises very low pause times on multi-terabyte heaps. JVM tuning will not be a tedious job because it is easy to tune as well. It is an experimental feature in JDK 11 later on it will available as full feature. It is scalable low latency Garbage Collector which means
it will have pause time less than 10ms no matter how big your heap is.
it is scalable, it can handle multi-terabyte heaps without affecting the performance.
Key features of ZGC are :
1. Concurrent
- Marking
- Relocation/compaction
- Relocation set selection
- reference processing
- StringTable cleaning
2. Single Generation
3. Load barriers
4. Colored pointers
5. Region based : heap is divided into small regions
6. Partial compaction
7. Non-uniform memory access (NUMA) aware
ZGC pause times do not increase with heap or live-set size.
Lets have a quick look at ZGC cycle:
1 - Pause Mark Start : This cycle start with this phase where thread stack scanned to find out the object pointers i.e roots. it is a time expensive operation because here GC needs to walk through the entire object graph.
2 - Pause Mark End : This phase is also known as synchronization point, to coordinate with marking phase. At the end of this phase GC will known the liveness of the objects which means GC will get to know which object is live and which is garbage. It also perform some more operations concurrently like
- reference processing and weak root cleaning: where GC takes care of soft, weak, and Phantom references and finalization.
- relocation set collection: where GC figures out which part of heap needs to be compacted to free up the memory.
3 - Pause Relocation Start : Here thread stacks are get scanned to handle roots pointing into the location sets then compacting the heap happens. Compacting the heap is also a time expensive operation because GC need to free up large contiguous chunks of memory and get back the memory available for new allocations.
This is end of GC cycle and this entire cycle gets completed in less than 10ms.
How to get started with JVM tuning with ZGC
Enable :
-XX : +UnlocakExperimentalVMOption (to enable the experimental feature in JVM)
-XX : +UseZGC
Tuning :
-Xmx <size> (Setting the max size)
-XX : ConcGCThreads=<number> (setting up the no of GC threads)
Logging :
-Xlog : gc (basic)
-Xlog : gc* (detailed logging)
Keep reading the articles, we are trying our best to get the best informative article on Java latest versions.
Also read the following topics to get understand entire garbage collection process in Java.
Comments
Post a Comment