By - Prakash Balodi
Independent consultant
(Clojure, FP and Linux enthusiast)
Prakash Balodi
Replaced with
Metaspace now!
A Garbage collector is an important part of Automatic Memory Management in JVM
Mainly responsible for–
True Memory leaks are not possible with Garbage collection, however not recovering Unused objects can result in -
Based on Weak Generational Hypothesis -
Generations = Separate pools for Differently aged Objects
Makes allocating new Objects and reclaiming memory pretty fast.
We can have different GC strategies for different generations.
GC can be tuned for -
Known as Performance triangle, tuning one will effect the other, so set your goals first.
Enable GC information logs -
-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps
-XX:PrintHeapAtGC -XX:PrintTenuringDistribution
Adjust the ratio between New and Old generations -
-XX:NewRatio (e.g. -XX:NewRatio=3 means ratio between the young and old gen is 1:3)
Profiling involves monitoring the JVM and getting insights about the application data
Different approaches for profiling -
Everything I Ever Learned About JVM Performance Tuning at Twitter - https://youtu.be/8wHx31mvSLY