How to force HotSpot JVM to overwrite heap dump file?
Asked Answered
E

1

6

I am dumping heap (OpenJDK 7) on OOM with

 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/jvm.hprof

startup opts for my VM. I dont have enough space on the disk and cant afford to store multiple dumps (heap size is 6g). Is there a way to force JVM to overwrite the dump file? Currently it will complain about 'file exists' and leave the existing dump intact. I have read Sun's docs but there doesnt seem to be any option to force overwrite

Erle answered 14/8, 2013 at 15:44 Comment(0)
B
3

No, there is no way to overwrite the file.

The relevant code is here: http://hg.openjdk.java.net/jdk/jdk/file/1ae823617395/src/hotspot/share/services/heapDumper.cpp#l465

Bremen answered 16/8, 2013 at 17:1 Comment(5)
This link is broken.Evermore
Fixed the link.Bremen
this is fixed in later JDKs if you manually trigger it, you can use --overwrite flag with jmapCroat
@Croat What later version? I'm using openjdk 11. And jmap --overwrite -dump:format=b,file=heap.hprof <pid>didn't work. Where does the --overwrite have to passed?Camail
@Camail you should be able to use jcmd with GC.heap_dumpCroat

© 2022 - 2024 — McMap. All rights reserved.