Skip to content

Reference

Jonathan Ross edited this page Jan 26, 2014 · 19 revisions

Command summary

histo x, y of PATH
skip (all | none | list | CLASSNAMES)
noskip (all | none| CLASSNAMES)
set (nogarbage | garbage | garbage only)
set (nothreshold | threshold N(k|m|g) (objects | bytes | retained))

Paths

Paths are of the form

Type1 name1 -> ... -> TypeN nameN

Where each name is an optional unique identifier, and Type is one of

  • A fully qualified Java class name, like java.util.HashMap
  • An unqualified class name in java.lang, like Integer
  • A Java regular expression, like com\.(mycompany|yourcompany)\.utils.*
  • Any of the above with some number of array dimensions, like Object[] or Integer[][]
  • A primitive array type, like int[]
  • The master GC root, denoted by root

There are eight kinds of path arrows, and more than one kind can be used in a path

  • -> is a direct outgoing reference
  • <- is a direct incoming reference
  • ->> is an outgoing reference that can skip objects
  • <<- is an incoming reference that can skip objects

The above path arrows traverse the object graph. To traverse the dominator tree, replace - with =

  • => means "directly dominates"
  • <= means "directly dominated by"
  • =>> means "indirectly dominates", can skip objects
  • <<= means "indirectly dominated by", can skip objects.

Skip filters

By default, indirect paths are the same as direct paths. By configuring skip filters, you can easily ignore intervening structural objects like collections and focus only on your own objects. Skip filters accept the same class name syntax as path types. Example:

skip java.util.*
skip .*[]

To reset filters to the default say skip none. You can also reverse what is matched by using skip all and noskip, for example:

skip all
noskip com.mycompany.*

To see what skip filters are set, enter skip by itself. To list all the skipped classes, enter skip list. To clear them, enter skip none.

Histograms

These show count, footprint and retained sizes for the matched objects. A histogram query is of the form

histo x, y of PATH

Where PATH is as defined above, with names x and y bound at some point in the path. To generate an ordinary histogram, make x and y the same name. You can also count objects relative to the class of another object instead of its own class, for example

histo x, x of com.mycompany.* =>> Integer x

will show the boxed integer footprint for your application's objects, but

histo x, y of com.mycompany.* x =>> Integer y

will show the counts relative to the classes that dominate them. (Read this as "histogram of x, count objects designated by y.")

Options

set garbage [only]
set nogarbage

By default, queries include only live objects. Issuing set garbage causes them to see non-live objects too. set garbage only makes queries run only on non-reachable objects (so dominator paths will not work here.) Be aware your heap dump may have no garbage.

set threshold M objects
set threshold N bytes
set threshold N retained
set nothreshold

Set the threshold for displaying class summaries in histograms to a minimum of M objects, N bytes directly used by an object, or N bytes retained. The histogram will also be sorted on that column. N can be optionally suffixed with k, m or g to indicate Kb, Mb or Gb. The default is 1K bytes

Clone this wiki locally