Memory & CPU issues
Purpose: Diagnose OOMs, GC thrash and CPU saturation on AEM instances with evidence instead of restarts.
Who this page is for
| Audience | Why it matters to you |
|---|---|
| Backend/platform engineers | Performance incident responders |
Memory: leak vs pressure
Heap graph over days tells you which problem you have:
sawtooth returning to same floor after full GC → healthy / just undersized if ceiling near max
floor RISING after every full GC → leak: something accumulates
sudden cliff → OOM after a deploy/feature → new allocation pattern: recent change lane
| Problem | Move |
|---|---|
| Leak | Heap dump at high-water (jmap / -XX:+HeapDumpOnOutOfMemoryError) → dominator tree in MAT: the top retained-size class usually names the culprit (unbounded cache, listener accumulating, resolver/session leak — the AEM classics) |
| Pressure (no leak) | Right-size heap from evidence; check Oak cache configs vs heap budget (tuning); reduce per-request allocation hotspots |
| OOM: Metaspace / direct buffers | Different pools — deploy churn (metaspace) or IO libraries (direct); the OOM message names the pool, read it precisely |
Session leaks deserve a call-out: "unclosed resolver" warnings in error.log correlate with both memory pressure and repository growth — grep for them during any memory investigation.
CPU saturation
Three thread dumps, 10s apart, DURING the event (jstack) — then read:
| Pattern in dumps | Meaning |
|---|---|
| Many threads in the same app stack frame | Your hot spot — usually a loop/query per request that should be cached (tuning ladder) |
| Threads parked waiting on one lock | Contention — synchronised singleton service doing slow work |
| GC threads dominating + tiny app time | It's memory pressure wearing a CPU costume — memory lane above |
| Render threads all busy, queue building | Load exceeds capacity: cold cache event? (dispatcher) or genuine capacity ⚡ |
| Indexing/compaction threads busy | Maintenance colliding with peak (windows) |
The restart temptation
A restart destroys the evidence and reschedules the incident. Capture first (dumps are minutes), THEN restart if service demands it (stabilise vs diagnose) — with the dumps in hand, the calm follow-up actually ends the pattern.