5

We are using the following JVM flags to run a Spring Boot app inside Docker (managed by Kubernetes)

-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp -XX:+ExitOnOutofMemoryError 

As expected, the container gets restarted upon an OOM exception. However, the heap dump created on exit (in /tmp) is no longer available as the container has been restarted. While we can map a persistent volume, is there a way in which we can have the heap dump written to STDOUT (as we already collect logs from STDOUT)? Using -XX:HeapDumpPath=/dev/stdout results in

*

Dumping heap to /dev/stdout ...
Unable to create /dev/stdout: File exists

*

Is there a simple work-around that I am missing here?

Ananth
  • 307
  • 3
  • 14
  • A HeapDump™ will mostly be huge (i.e., heap size, probably at least a couple hundred MB). Do you really want to dump it to std out? – D. Kovács Feb 15 '18 at 13:34
  • I understand it can be huge. But, as I mentioned, we already route STDOUT content to our logging infrastructure which can handle the same. – Ananth Feb 16 '18 at 07:07

2 Answers2

0

Personally, I would use a Docker Volume to be mounted in the Docker image and store there the memory dumps that, as stated previously, can be GBs big.

senape
  • 342
  • 2
  • 12
0
-XX:HeapDumpPath=/dev/stdout/`date`.hprof
TT.
  • 15,774
  • 6
  • 47
  • 88
drtvhood
  • 17
  • 1
  • 7