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,11 @@
$ java -Xmx160m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=docs/output/heap.hprof -jar target/classloader-leak.jar
classloader-leak: driving repeated plugin reloads to OOM, class=com.ankurm.oomplugin.PluginTask
classloader-leak: reloads=150 livePlugins=150
classloader-leak: reloads=300 livePlugins=300
classloader-leak: reloads=450 livePlugins=450
java.lang.OutOfMemoryError: Java heap space
Dumping heap to docs/output/heap.hprof ...
Heap dump file created [138919083 bytes in 0.140 secs]
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "main"
@@ -0,0 +1,24 @@
Eclipse MAT 1.17.0 batch report (org.eclipse.mat.api:suspects) on heap.hprof -- Problem Suspect 1
================================================================================================
Problem Suspect 1 The class com.ankurm.oomdemo.ClassloaderLeakApplication , loaded by
org.springframework.boot.loader.launch.LaunchedClassLoader @ 0xf606bba8 , occupies 123,132,768
(95.35%) bytes. The top consumers of its minimum retained heap are byte[] (1,412 instances
totaling 122,739,984), java.util.concurrent.ConcurrentHashMap (1,404 instances totaling 89,856),
and java.util.concurrent.ConcurrentHashMap$Node[] (936 instances totaling 74,880). The memory is
accumulated in one instance of java.lang.Object[] , loaded by <system class loader> , which
occupies 123,131,144 (95.35%) bytes. Thread java.lang.Thread @ 0xf60cad68 main has a local
variable or reference to class com.ankurm.oomdemo.ClassloaderLeakApplication @ 0xf60000b0 which
is on the shortest path to java.lang.Object[549] @ 0xf7b40d50 . The thread java.lang.Thread @
0xf60cad68 main keeps local variables with total size 109,632 (0.08%) bytes. The top consumers
of its minimum retained heap are byte[] (1,412 instances totaling 122,739,984),
java.util.concurrent.ConcurrentHashMap (1,404 instances totaling 89,856), and
java.util.concurrent.ConcurrentHashMap$Node[] (936 instances totaling 74,880). Significant stack
frames and local variables org.springframework.boot.SpringApplication.run(Ljava/lang/Class;[Ljav
a/lang/String;)Lorg/springframework/context/ConfigurableApplicationContext;
(SpringApplication.java:1354) class com.ankurm.oomdemo.ClassloaderLeakApplication @ 0xf60000b0
retains 123,132,768 (95.35%) bytes org.springframework.boot.loader.launch.Launcher.launch(Ljava/
lang/ClassLoader;Ljava/lang/String;[Ljava/lang/String;)V (Launcher.java:106) class
com.ankurm.oomdemo.ClassloaderLeakApplication @ 0xf60000b0 retains 123,132,768 (95.35%) bytes
The stacktrace of this Thread is available. See stacktrace . See stacktrace with involved local
variables .