The answer marked as correct isn't correct anymore.
As Sumit says, it will cause a Full GC only when the live option is used (in both histo & dump operations).
Java 7 and Java 8 have this option
-histo[:live]
Prints a histogram of the heap. For each Java class, the number of objects, memory size in bytes, and the fully qualified class names are printed. The JVM internal class names are printed with an asterisk (*) prefix. If the live suboption is specified, then only active objects are counted.
-dump:[live,] format=b, file=filename
Dumps the Java heap in hprof binary format to filename. The live suboption is optional, but when specified, only the active objects in the heap are dumped. To browse the heap dump, you can use the jhat(1) command to read the generated file.
You could aldo use the jcmd command with the operation GC.heap_dump
and the option -all
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]
Arguments:
- filename : Name of the dump file (STRING, no default value)
Options: (options must be specified using the or =
syntax)
- -all : [optional] Dump all objects, including unreachable objects (BOOLEAN, false)
Example: jcmd 3181 GC.heap_dump -all dump
You could add the -XX:+PrintGCDetails
flag to see if a Full GC is hapenning.
For example, when I use jcmd without -all I see something like this.
200,658: [Full GC (Heap Dump Initiated GC) 200,658: [CMS: 5040K->4158K(18432K), 0,0171885 secs] 11239K->4158K(25856K), [Metaspace: 18053K->18053K(1064960K)], 0,0173941 secs] [Times: user=0,01 sys=0,00, real=0,02 secs]