JVM Memory Model, GC Log Analysis, and Production Parameter Optimization
This article examines production JVM memory architecture, explains GC log generation and analysis, details the ParNew + CMS collector behavior, and provides practical parameter tuning recommendations to optimize heap size, young generation, and garbage collection for stable Java applications in production environments.
This article begins by describing the common scenario where developers need to understand JVM configuration, heap and stack memory sizing, and garbage collector strategies in a production environment.
It then presents a series of sections covering:
Production GC log file examples.
An overview of the JDK 1.6 memory layout, including young generation, old generation, permanent generation, native method area, JVM stacks, and program counters.
Details of the production environment (JDK 1.6, WebLogic container) and a discussion on outdated JDK versions.
Initial JVM heap parameters (e.g., -Xms4096M , -Xmx4096M , -XX:MaxPermSize=1024M ) with commentary on missing settings such as -Xmn and -XX:PermSize .
A step‑by‑step analysis of a sample GC log line, highlighting frequent Minor GC (ParNew) events and the small size of the young generation (~150 MB) compared to a 4 GB heap.
Examination of CMS Full GC behavior, including promotion failures and concurrent mode failures, illustrated with screenshots.
Discussion of the ParNew + CMS collector combination, its typical use before JDK 1.8, and the observed issues in production.
Proposed solutions: increasing young generation size ( -Xmn1500M , -XX:SurvivorRatio=8 ), enabling CMS compaction ( -XX:+UseCMSCompactAtFullCollection ), and adjusting occupancy thresholds.
A final recommended JVM parameter set for production, including heap size, young generation size, PermSize, thread stack size, survivor ratio, and GC logging options.
The article also introduces a method for estimating online system memory usage, providing a table of Java primitive type sizes and explaining object header and padding calculations. Sample Java classes are shown with public class JavaBeanA { int a; byte b; String c; double d; ... } and the resulting size estimation (approximately 136 bytes per instance).
Using these calculations, the article demonstrates how to approximate the memory consumption per second for a given object creation rate, and how this relates to GC frequency.
In the concluding section, the author emphasizes the importance of enlarging the young generation, reducing unnecessary object creation, and fine‑tuning JVM parameters to minimize Minor and Full GC occurrences in production systems.
Additional resources and related articles on JVM compilation, class loading, and performance troubleshooting are linked at the end.
FunTester
10k followers, 1k articles | completely useless
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.