On Wed, 27 Mar 2024 13:44:42 GMT, Matthias Baesken <mbaes...@openjdk.org> wrote:
>> Currently jcmd command GC.heap_dump only works with an additionally provided >> file name. >> Syntax : GC.heap_dump [options] <filename> >> >> In case the JVM has the XX - flag HeapDumpPath set, we should support an >> additional mode where the <filename> is optional. >> In case the filename is NOT set, we take the HeapDumpPath (file or >> directory); >> >> new syntax : >> GC.heap_dump [options] <filename> .. has precedence over second option >> GC.heap_dump [options] …in case -XX: HeapDumpPath=p is set >> >> This would be a simplification e.g. for support cases where a filename or >> directory is set at JVM startup with -XX: HeapDumpPath=p and writing to the >> path is intended/recommended for usage also in the jcmd case. > > Matthias Baesken has updated the pull request incrementally with one > additional commit since the last revision: > > adjust java.1 man page I don't have strong opinion if it's good to have default file path for `jcmd GC.heap_dump`, just some thoughts. We have several ways to heap dump: 1. `-XX:+HeapDumpOnOutOfMemoryError` 2. `-XX:+HeapDumpBeforeFullGC`, `-XX:+HeapDumpAfterFullGC` in the case `HeapDumpPath` and `HeapDumpGzipLevel` are used (this is not mentioned in the options' description, need to fix it) 3. `jcmd GC.heap_dump` 4. `jmap -dump` it uses "dumpheap" Attach operation, implemented by AttachListener directly 5. `HotSpotDiagnosticMXBean.dumpHeap()`; Current patch looks inconsistent: If HeapDumpPath is used as default, HeapDumpGzipLevel should be used as default too (note that default path has different extension depending on HeapDumpGzipLevel); If (3) has defaults, why (4) and (maybe) (5) don't have the same defaults? ------------- PR Comment: https://git.openjdk.org/jdk/pull/18190#issuecomment-2040728112