If you know that the lifespan of your objects is a long game with parameters that specify the size of the areas relative to each other.
You can establish relationships in young generation
and old generation
(eden and ternured spaces), as well as survivors.
The goal is to minimize complete garbage collection by allowing a small garbage collection to free up all memory.
You prohibit garbage collection to free objects while keeping them available in your application. I mean, you only need to make sure that those objects are removed by small collections of garbage.
Enable options
-verbose:gc -Xloggc:/opt/tomcat/logs/gc.out -XX:+PrintGCDetails -XX:+PrintGCTimeStamps
Then, using the GCViewer tool , you can see the time spent in gc
and the number (size) of deleted objects. Among some useful indicators.
source share