spring-boot-demo-oom: five real memory-leak demos with captured OOM + MAT evidence

This commit is contained in:
2026-10-01 12:11:56 +00:00
commit fd035a79e8
41 changed files with 1317 additions and 0 deletions
@@ -0,0 +1,19 @@
$ java -Xmx220m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=docs/output/heap.hprof -jar target/threadlocal-leak.jar
threadlocal-leak: submitted=3017200
threadlocal-leak: submitted=3017600
threadlocal-leak: submitted=3018000
threadlocal-leak: submitted=3018400
threadlocal-leak: submitted=3018800
java.lang.OutOfMemoryError: Java heap space
Dumping heap to docs/output/heap.hprof ...
Heap dump file created [300071460 bytes in 1.908 secs]
Exception in thread "req-worker-1" java.lang.OutOfMemoryError: Java heap space
at com.ankurm.oomdemo.ThreadLocalLeakApplication.handleOneRequest(ThreadLocalLeakApplication.java:61)
at com.ankurm.oomdemo.ThreadLocalLeakApplication.lambda$driveLeak$1(ThreadLocalLeakApplication.java:47)
at com.ankurm.oomdemo.ThreadLocalLeakApplication$$Lambda/0x000000002d25dce8.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1090)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:614)
at java.base/java.lang.Thread.runWith(Thread.java:1487)
at java.base/java.lang.Thread.run(Thread.java:1474)
@@ -0,0 +1,23 @@
Eclipse MAT 1.17.0 batch report (org.eclipse.mat.api:suspects) on heap.hprof -- Problem Suspect 1
================================================================================================
Problem Suspect 1 One instance of
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor$1 loaded by
org.springframework.boot.loader.launch.LaunchedClassLoader @ 0xf2434790 occupies 172,593,776
(82.46%) bytes. The top consumers of its minimum retained heap are
com.ankurm.oomdemo.ThreadLocalLeakApplication$$Lambda+0x000000006f25dce8 (3,082,020 instances
totaling 98,624,640), java.util.concurrent.LinkedBlockingQueue$Node (3,082,021 instances
totaling 73,968,504), and java.util.HashMap$Node (4 instances totaling 128). Thread
java.lang.Thread @ 0xf2508e50 req-worker-1 has a local variable or reference to
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor$1 @ 0xf2508f60 which is on the
shortest path to org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor$1 @ 0xf2508f60
. The thread java.lang.Thread @ 0xf2508e50 req-worker-1 keeps local variables with total size
8,391,448 (4.01%) bytes. The top consumers of its minimum retained heap are
com.ankurm.oomdemo.ThreadLocalLeakApplication$$Lambda+0x000000006f25dce8 (3,082,020 instances
totaling 98,624,640), java.util.concurrent.LinkedBlockingQueue$Node (3,082,021 instances
totaling 73,968,504), and java.util.HashMap$Node (4 instances totaling 128). Significant stack
frames and local variables java.util.concurrent.ThreadPoolExecutor.runWorker(Ljava/util/concurre
nt/ThreadPoolExecutor$Worker;)V (ThreadPoolExecutor.java:1090)
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor$1 @ 0xf2508f60 retains
172,593,776 (82.46%) bytes The stacktrace of this Thread is available. See stacktrace . See
stacktrace with involved local variables .