Trace: • JVx Code Snippets
Configure CG for application servers
We didn't find memory leaks in JVx, but sometimes memory consumption is higher than expected. We tried a lot of settings and profiling tools to find problems in JVX, without success. In the end we configured the gc to free memory reliable. With one of our JVM settings, application server memory consumption is as expected:
- G1GC (available in Java 8 and later)
-XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:+ExplicitGCInvokesConcurrent -XX:+UseStringDeduplication -XX:InitiatingHeapOccupancyPercent=0
This will release all the memory sooner or later even when idle (8 minutes)
- ZGC (JVM >= 11, slightly more memory intensive)
-XX:+UseZGC -XX:+ExplicitGCInvokesConcurrent -XX:ZCollectionInterval=30
- ZGC (JVM >= 21)
-XX:+UseZGC -XX:+ZGenerational -XX:+UnlockExperimentalVMOptions -XX:+ExplicitGCInvokesConcurrent -XX:+ZProactive -XX:ZCollectionInterval=30