onheap

onheap

Synopsis
onheap [--minCount <count>] [--minTotalSize <size>] [--className <size>]* Print per-class heap usage statistics
Details
The onheap command scans the heap to gather statistics on heap usage. Then it outputs a per-class breakdown, showing the number of instances of each class and the total space used by those instances.

When you run the command with no options, the output report shows the heap usage for all classes. This is typically too large to be directly useful. If you are looking for statistics for specific classes, you can pipe the output to the grep command and select the classes of interest with a regex. If you are trying to find out what classes are using a lot of space, you can use the onheap command's options to limit the output as follows:

  • --minCount <count> : this option filters out any classes that have less than <count> instances.
  • --minTotalSize <size> : this option filters out any classes for which the total space usage is less than <size> bytes.
  • --className <substring> : this option filters out any classes whose name doesn't contain <substring>.