How to trace a Java Memory Leak
summary
Covers concrete debugging steps: which JVM flags to enable, how to ensure a heap dump survives Kubernetes, and loading dumps into VisualVM, IntelliJ or Eclipse MAT; demonstrates analysis of 10 real leaks pulled from a repository of heap dumps from 150+ companies, and shows root causes: ThreadLocal retention, non‑static inner classes holding parents, high‑cardinality micrometer tags in Spring Boot 2, Hibernate first‑level cache and self‑submit executor queues. Provides an automated MCP workflow, a downloadable repo, and a €10 bounty for new leaks not yet catalogued.
AI-written summary · about
chapters (30)
- 0:00Introduction
- 2:08Out of memory basics
- 6:09Heap dump importance
- 6:53Heap dump analysis tools
- 8:21Shallow vs retained size
- 11:33Matrix cardinality leak
- 16:30Spring Boot metric tagging
- 17:17Hibernate streaming query
- 20:07Memory Analyzer tool
- 22:20Hibernate first level cache
- 25:13DIY cache dangers
- 27:44Cache hit ratio monitoring
- 28:04Cache key mutation issue
- 31:55HashCode equals pitfalls
- 36:33Static inner class leak
- 38:45Anonymous class reference
- 44:10JSON parsing big decimal
- 48:52Kafka popcorn downtime
- 49:58Sublist memory leak
- 57:21Thread local leak
- 1:03:23ThreadLocal removal pattern
- 1:05:30ThreadLocal in legacy libs
- 1:09:24Shutdown hook leak
- 1:11:33CompletableFuture pitfalls
- 1:16:18Thread pool queue limits
- 1:19:36Fixed thread pool solution
- 1:21:44Async annotation dangers
- 1:25:09Self-submit deadlock
- 1:27:17Virtual thread deadlock
- 1:30:07Key takeaways summary
