javagarbage-collectionheap-memoryheap-dumpjcmd

Java Heapdump - jsm <pid> -all GC.heap_dump


There is no -all option for jcmd command as per documentation. https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr006.html

  1. execute jcmd with -all option. GC is not triggered and can not see [Full GC (Heap Dump Initiated GC) in GC logs.

  2. execute jcmd with -all option. GC is triggered and can see [Full GC (Heap Dump Initiated GC) in GC logs.

Is there any specific behaviour with -all option and not mentioned in documentation.


Solution

  • To get help on a jcmd (sub)command, use “help command”, but note that you still have to specify a pid to meet jcmd’s formal command line pattern, i.e.

    jcmd 0 help GC.heap_dump
    

    which prints

    GC.heap_dump
    Generate a HPROF format dump of the Java heap.
    
    Impact: High: Depends on Java heap size and content. Request a full GC unless the '-all' option is specified.
    
    Permission: java.lang.management.ManagementPermission(monitor)
    
    Syntax : GC.heap_dump [options] <filename>
    
    Arguments:
            filename :  Name of the dump file (STRING, no default value)
    
    Options: (options must be specified using the <key> or <key>=<value> syntax)
            -all : [optional] Dump all objects, including unreachable objects (BOOLEAN, false)
            -gz : [optional] If specified, the heap dump is written in gzipped format using the given compression level. 1 (recommended) is the fastest, 9 the strongest compression. (INT, 1)
    

    (tested with JDK 17.0.2+8)