Files
zgc-jdk25-benchmarks/flags/docs/output/08-heapdumponoutofmemoryerror.txt
asmhatreandClaude Sonnet 5 2f88734f5d Add flags: production JVM flag cheat sheet for Spring Boot on JDK 25/27
MaxRAMPercentage vs a hardcoded -Xmx, -XX:-UseContainerSupport, the
ActiveProcessorCount lie, and which diagnostic flags are worth leaving
on in prod, verified in real Docker containers on JDK 25 and JDK 27.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-10-01 04:34:04 +00:00

24 lines
1.1 KiB
Plaintext

$ docker run --rm --memory=256m -v $PWD/docker/memoryhog.jar:/memoryhog.jar --entrypoint java flags-demo:jdk25-jdk \
-XX:MaxRAMPercentage=75 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/dumps/heap.hprof \
-cp /memoryhog.jar MemoryHog 24 200
=== Diagnostic: -XX:+HeapDumpOnOutOfMemoryError actually leaves a dump behind ===
MemoryHog starting: chunk=24MB sleep=200ms
held=24MB heapUsed=25MB heapMax=185MB freeHeap=6MB
held=48MB heapUsed=49MB heapMax=185MB freeHeap=6MB
held=72MB heapUsed=73MB heapMax=185MB freeHeap=27MB
held=96MB heapUsed=98MB heapMax=185MB freeHeap=14MB
held=120MB heapUsed=122MB heapMax=185MB freeHeap=24MB
held=144MB heapUsed=146MB heapMax=185MB freeHeap=35MB
held=168MB heapUsed=170MB heapMax=185MB freeHeap=11MB
java.lang.OutOfMemoryError: Java heap space
Dumping heap to /dumps/heap.hprof ...
Heap dump file created [180390818 bytes in 1.028 secs]
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at MemoryHog.main(MemoryHog.java:21)
exit=1
total 176176
drwxr-xr-x 2 root root 4096 Oct 1 04:29 .
drwxr-xr-x 3 root root 4096 Oct 1 04:29 ..
-rw------- 1 root root 180390818 Oct 1 04:29 heap.hprof