Optimized for Java 21 with support for G1 and ZGC garbage collectors.
Memory Distribution
Heap Memory: 384MB
Young Generation: 154MB
Old Generation: 230MB
Non-Heap Memory: 344MB
Metaspace: 150MB
Code Cache: 64MB
Thread Stacks: 85MB
Compressed Class: 45MB
Other Memory: 44MB
Direct Buffers: 10MB
Native Memory: 22MB
JVM Overhead: 12MB
Recommended Total Memory: 776MB
Includes a safety margin of 4MB (0.52%)
Recommended JVM Parameters for Java 21
-Xms268m -Xmx384m
Sets the minimum and maximum heap sizes. Making them equal reduces memory reallocations. It is recommended to set Xms to 70% of Xmx to allow dynamic adjustments without wasting initial memory.
-XX:+UseG1GC
The G1 is the default garbage collector in Java 21. It is a low-latency collector that divides the heap into regions, ideal for heaps larger than 4GB and applications requiring predictable pause times.
-XX:MaxGCPauseMillis=200
Sets the maximum pause time goal for G1 collections in milliseconds. G1 will attempt to adjust its behavior to keep pauses below this value. A lower value results in shorter pauses but may reduce throughput.
-Xss1M
Sets the stack size for each thread. The default value is usually sufficient. Increase it if you encounter StackOverflowError exceptions or deep recursion.
-XX:ReservedCodeCacheSize=64m
Space reserved for JIT-compiled code. Important for applications that use a lot of dynamic code or have many classes. Increase it if you see messages about a full code cache. You can check the current value with the parameter -XX:+PrintFlagsFinal.
-XX:MaxDirectMemorySize=10m
Maximum limit for direct memory (NIO). Important for applications that use a lot of NIO or Netty. A value that is too high can cause native OOM issues.
-XX:+ExitOnOutOfMemoryError
Exit the JVM when an OutOfMemoryError is encountered. This can help avoid a situation where the JVM keeps running and consuming more memory without being able to recover.
-XX:+UnlockDiagnosticVMOptions
Unlocks additional diagnostic options for JVM, enabling more advanced configuration and debugging options.
-XX:NativeMemoryTracking=summary
Enables Native Memory Tracking (NMT) and provides a summary of native memory usage. Useful for diagnosing memory issues related to native memory allocations.
-XX:+PrintNMTStatistics
Prints statistics about native memory usage. Helps in debugging and understanding the memory consumption of native code.