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?