Measure and tune Java memory use

8 steps · about 4 h 45 min · Intermediate

  1. Map the garbage collector's job (reference, Oracle Java documentation, 35 min)

    Connect allocation, reachability, collection pauses and throughput before changing runtime options.

  2. Choose performance measures (reference, Oracle Java documentation, 35 min)

    Define latency, throughput and footprint goals so tuning has an explicit target.

  3. Enable useful GC evidence (reference, Oracle Java documentation, 35 min)

    Select diagnostic logging and heap settings deliberately rather than copying an option bundle.

  4. Inspect a running JVM (reference, Oracle Java documentation, 35 min)

    Query heap, class and native-memory information through a supported diagnostic command.

  5. Record runtime behaviour (guide, Oracle Java documentation, 40 min)

    Capture allocations, pauses and application events with low-overhead flight recordings.

  6. Observe memory programmatically (reference, Oracle Java API, 30 min)

    Expose stable heap and non-heap measurements without scraping human-oriented tool output.

  7. Distinguish pressure from leaks (guide, Oracle troubleshooting guide, 40 min)

    Use growth after full collection and retained references to test whether memory is genuinely leaking.

  8. Compare heap snapshots (reference, Oracle Java documentation, 35 min)

    Capture histograms or dumps before and after a reproducible workload and verify the effect of one change.