Skip to main content

Production HotSpot JVM Tuning Matrix

Operating dynamic bytecode engines requires careful JVM flag tuning to avoid long GC pauses and Metaspace starvation.


java -server \
-XX:+UseG1GC \
-XX:MaxGCPauseMillis=200 \
-XX:InitiatingHeapOccupancyPercent=45 \
-XX:MaxMetaspaceSize=256m \
-XX:SoftRefLRUPolicyMSPerMB=1000 \
-XX:CompileThreshold=10000 \
-XX:MaxInlineSize=35 \
-XX:FreqInlineSize=325 \
-XX:+TieredCompilation \
-XX:+UseCompressedOops \
-jar engine-core-1.0.0-SNAPSHOT.jar execute ...

Flag Justification & Mechanical Sympathy​

JVM FlagRecommended ValueEngineering Rationale
-XX:+UseG1GCDefaultPredictable low-latency GC pauses for mixed short-lived contexts and long-lived compiled class references.
-XX:MaxGCPauseMillis=200100 - 200Bounds Stop-The-World (STW) pause times to meet strict API latency SLAs.
-XX:MaxMetaspaceSize=256m256mHard cap preventing uncollected ClassLoaders from exhausting physical host memory.
-XX:SoftRefLRUPolicyMSPerMB1000Retains L2 soft cache entries for 1 second per free MB of heap space before GC reclamation.
-XX:CompileThreshold=1000010000Invocation count at which C2 triggers aggressive server optimizations.
-XX:MaxInlineSize=3535 (bytes)Restricts non-frequent bytecode method inlining to prevent I-Cache thrashing.
-XX:FreqInlineSize=325325 (bytes)Allows hot CompiledRule::eval methods to inline directly into call sites.