Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8267667

Add option to jcmd GC.heap_dump to use existing file

XMLWordPrintable

    • behavioral
    • minimal
    • Only adds additional flag to jcmd GC.heap_dump.
    • add/remove/modify command line option
    • JDK

      Summary

      Add an option to the jcmd GC.heap_dump command to allow it overwrite an existing file.

      Problem

      The GC.heap_dump command expects to create a new file for heap dump and it bails out if the target file exists.

      A user may want to overwrite the existing target file.

      Also, on many operating systems it is possible to create special file-like objects, which are represented by files on the filesystem. Such file-like objects in many aspects behave like regular files. Now a file-like object can be provided as the target to GC.heap_dump, but it fails since the target already exists. If GC.heap_dump has an option to overwrite the target file, it will be possible to use a file-like object for the heap dump. Missing option to overwrite the target file is the only blocker to use file-like objects with GC.heap_dump.

      Solution

      Add an option to overwrite an existing target file specified for the diagnostic command GC.heap_dump.

      The option enables the transparent use of file-like objects with GC.heap_dump without any additional change in the JVM.

      Specification

      Add a boolean option overwrite to the GC.heap_dump diagnostic command. If it is specified and the target file exists, the file will be rewritten. If it is specified and the target file does not exist, it will be created. If the option is not specified, the behavior is not changed, and an attempt to use an existing file will fail.

      Example invocation:

      jcmd <pid|main class> GC.heap_dump -overwrite <existing-file-name>

            akozlov Anton Kozlov
            akozlov Anton Kozlov
            Alan Bateman, Christoph Langer
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: