Aisle between two rows of black server racks with small status lights in a supercomputing centre

Field guides for JVM operators

When production stops, the JVM already knows why.

Heap dumps, thread dumps, GC logs, Native Memory Tracking, Flight Recorder: the evidence is built into the JDK. The Safepoint explains how to collect it, how to read it and which flags actually change the outcome, with every option checked against the official documentation.

Photo: Derrick Coetzee, Wikimedia Commons, CC0

Start from the symptom

Paste-able error messages, mapped to the guide that explains them

Several laptop memory modules with black chips and gold contacts lying on a light surface In focus · Memory

OutOfMemoryError: Direct buffer memory, and what MaxDirectMemorySize really defaults to

The heap looks healthy, the process dies anyway. How NIO direct buffers are limited, why the default follows -Xmx, why -XX:+DisableExplicitGC makes things worse, and how to find who holds the buffers.

Read the guide
01 / memory

Memory

Heap, direct buffers, Metaspace, code cache and native memory: where a JVM's footprint goes and how to find a leak.

All memory guides
Two metal control knobs on a brushed panel, one marked Warmer and Cooler, the other Off, Hi, Med and LoMemory

Where to set the heap in Tomcat, Eclipse, Maven, Gradle

Tomcat, Eclipse, Maven and Gradle each start several JVMs. Find the one that ran out of heap, then set -Xmx in the one place that reaches it.

A sheet of red and white "hello my name is" name tag stickers next to two black marker pens on a black surfaceMemory

Compact object headers

JDK 27 turns on 8-byte object headers by default. Which objects really shrink, how to measure the gain on your heap, and when to turn them off.

A wall of old bronze post office boxes with four-digit numbers on white labels, arranged around a closed service window in a post officeMemory

Compressed oops

Raise -Xmx from 31g to 32g and every reference doubles in size. How compressed oops work, how to see which mode you got, and when crossing the line is worth it.

A steel stacker parking structure in a city street, with cars parked on three levels of platforms and every visible slot takenMemory

Java heap space

The most common OutOfMemoryError has three different causes. How to tell an undersized heap, a leak and one oversized request apart.

A thick tree root running across bare, pebbly soil at the foot of a trunkMemory

GC roots and memory leaks

What counts as a GC root, the usual accidental references, and how to walk from a suspect object back to its root.

Rear of a server rack with rows of rack servers and neatly bundled network cablesMemory

Taking and reading a heap dump

Capture safely with jcmd, dump automatically on OOM, then read the dominator tree and paths to GC roots.

Server racks with bundles of yellow network cables next to a power distribution cabinet in a data centreMemory

Native Memory Tracking

Heap is only part of the process: read the NMT summary, diff against a baseline, and know what it cannot see.

Macro photograph of a dark printed circuit board with silkscreen labels, pads and small surface-mount componentsMemory

The code cache and ReservedCodeCacheSize

What happens when compiled code runs out of room, the 240 MB default, segmented heaps and how to monitor them.

Rows of small wooden card catalogue drawers with metal pullsMemory

Metaspace and class loader leaks

Class metadata outside the heap: the flags, the jcmd views, and how redeploys leak class loaders.

A desktop motherboard with one memory module installed and two empty DIMM slots beside itMemory

The AI memory squeeze

What AI demand did to DRAM prices, what a gigabyte costs in the cloud, and how to run the same JVM service on less memory.

02 / gc

Garbage collection

Choosing a collector, tuning G1 and reading the unified GC log without guesswork.

All GC guides
03 / threads

Threads & CPU

Thread dumps, runaway CPU, locks and virtual threads.

All thread guides
04 / ops

Production

Running the JVM in containers, sizing the services around AI models and recording what the JVM does with Flight Recorder.

All production guides

How these guides are written

Each guide starts from a symptom seen in production and ends with commands you can run. Option names, defaults and behaviours are taken from primary sources: the java, jcmd and jfr reference pages, the HotSpot tuning and troubleshooting guides, JDK Enhancement Proposals and the OpenJDK source. Each guide lists them at the end.

Defaults change between JDK releases. Where a behaviour depends on the version, the guide says which release introduced or changed it. When in doubt, ask the JVM itself: java -XX:+PrintFlagsFinal -version prints every option with its effective value. More on the method on the about page; the full list is on all articles.