RFC: Allowing existing file when writing a heap dump

Alan Bateman Alan.Bateman at oracle.com
Wed Feb 24 20:39:45 UTC 2021


On 24/02/2021 20:16, Chris Plummer wrote:
> Right now the failure helps the user avoid potentially inadvertently 
> overwriting a file, so I think at the very least it should continue to 
> fail for regular files. I'm a bit less clear on how pipes, ttys, and 
> domain sockets work here. Are you saying they are all pseudo files 
> that already exist and can't be deleted, and therefore you currently 
> can't dump the heap to them?
I added the built-in heap dumper in JDK 6 and changed jmap at the time 
to invoke it. The reason for not overriding existing files was security 
concerns and also the potential for accidents. One use-case at the time 
for specifying an existing file was to append the dump to an existing 
heap dump, meaning several heap dumps in the same file that could be 
used for comparison purposes. We didn't go too far on extending the 
hprof binary format to support that. For the current discussion then I 
think it will be ambiguous when the file already exists, it doesn't 
matter if it's a tty or socket file. I think it would require an 
additional hint from the user as to whether they are trying to override 
the file or write to the tty or socket.

-Alan


More information about the serviceability-dev mailing list