Currently you cannot overwrite an already existing heap dump with jcmd GC.heap_dump, neither can you write to named pipes (Windows) or domain sockets or similar devices (Unix).
The enhancement proposes to add two additional switches to the GC.heap_dump diagnostic command which would enable both use cases:
- an '-overwrite' flag would allow the user to overwrite (using truncation) an already existing heap dump; if the specified file is not already present, it would be created as without the flag.
- a '-stream' flag would allow to write to special files like pipes, domain sockets or ttys; the file will not be truncated and if it is not already present, an error will be reported instead of creating it.
Note that we would not check if the file argument to '-stream' is really a special file or that the argument to '-overwrite' isn't a special file.
The enhancement proposes to add two additional switches to the GC.heap_dump diagnostic command which would enable both use cases:
- an '-overwrite' flag would allow the user to overwrite (using truncation) an already existing heap dump; if the specified file is not already present, it would be created as without the flag.
- a '-stream' flag would allow to write to special files like pipes, domain sockets or ttys; the file will not be truncated and if it is not already present, an error will be reported instead of creating it.
Note that we would not check if the file argument to '-stream' is really a special file or that the argument to '-overwrite' isn't a special file.
- duplicates
-
JDK-8267666 Add option to jcmd GC.heap_dump to use existing file
- Resolved
-
JDK-8200579 Unable to overwrite files with jmap -dump:file=<path>
- Closed