Package org.eclipse.mat.parser.internal

# Class SnapshotImpl

java.lang.Object
org.eclipse.mat.parser.internal.SnapshotImpl

All Implemented Interfaces:
  `ISnapshot`

public final class SnapshotImpl extends Object implements ISnapshot
The implementation of the `ISnapshot` representing the entire heap dump.

## Method Summary

Modifier and Type
Method
Description
`void`
`calculateDominatorTree(IProgressListener listener)`
Calculates the dominator tree after a parse
`void`
`calculateMinRetainedHeapSizeForClasses(IProgressListener listener)`
Calculate for each class an approximation for the retained size of all instances of that class.
`static SnapshotImpl`
`create(XSnapshotInfo snapshotInfo, String objectReaderUniqueIdentifier, IObjectReader heapObjectReader, HashMapIntObject<ClassImpl> classCache, HashMapIntObject<XGCRootInfo[]> roots, HashMapIntObject<HashMapIntObject<XGCRootInfo[]>> rootsPerThread, BitField arrayObjects, IndexManager indexManager, IProgressListener listener)`
Create the snapshot after a fresh parse.
`void`
`dispose()`
Dispose the whole snapshot.
`Collection<IClass>`
`getClasses()`
Get all classes.
`Collection<IClass>`
`getClassesByName(String name, boolean includeSubClasses)`
Get all classes by name.
`Collection<IClass>`
`getClassesByName(Pattern namePattern, boolean includeSubClasses)`
Get all classes by name pattern.
`String`
`getClassLoaderLabel(int objectId)`
Finds the name associated with a class loader.
`IClass`
`getClassOf(int objectId)`
Get object abstracting the real Java Class this object was an instance of in the heap dump identified by the given id.
`DominatorsSummary`
`getDominatorsOf(int[] objectIds, Pattern excludePattern, IProgressListener progressListener)`
Get a summary of the dominators for all the given objects.
`GCRootInfo[]`
`getGCRootInfo(int objectId)`
Get the GC root info for an object.
`int[]`
`getGCRoots()`
Get all GC roots.
`IObjectReader`
`getHeapObjectReader()`
Gets the reader for the particular snapshot type to read individual objects.
`long`
`getHeapSize(int objectId)`
Get heap size for just the given object.
`long`
`getHeapSize(int[] objectIds)`
Get the total shallow heap size for a set of objects.
`Histogram`
`getHistogram(int[] objectIds, IProgressListener progressMonitor)`
Get histogram for some specific objects - usually the result of other calls to the snapshot.
`Histogram`
`getHistogram(IProgressListener listener)`
Get histogram for the whole snapshot.
`int[]`
`getImmediateDominatedIds(int objectId)`
Get objects the given object directly dominates, i.e.
`int`
`getImmediateDominatorId(int objectId)`
Get object which directly dominates the given object, i.e.
`int[]`
`getInboundRefererIds(int objectId)`
Get all objects referencing the given object.
`int[]`
`getInboundRefererIds(int[] objectIds, IProgressListener progressMonitor)`
Get all objects referencing the given objects.
`IndexManager`
`getIndexManager()`
Gets all the indexes for the snapshot.
`int[]`
`getMinRetainedSet(int[] objectIds, IProgressListener progressMonitor)`
Calculate the minimum retained set of objects for the given objects (including the given objects).
`long`
`getMinRetainedSize(int[] objectIds, IProgressListener progressMonitor)`
Calculate the minimum retained size for the given objects.
`IMultiplePathsFromGCRootsComputer`
`getMultiplePathsFromGCRoots(int[] objectIds, Map<IClass,Set<String>> excludeList)`
Returns an IMultiplePathsFromGCRootsComputer object, which can be used to calculate the shortest path from the GC roots to each of objects in the specified object set.
`IObject`
`getObject(int objectId)`
Get object abstracting the real Java Object from the heap dump identified by the given id.
`int[]`
`getOutboundReferentIds(int objectId)`
Get all objects referenced by the given object.
`int[]`
`getOutboundReferentIds(int[] objectIds, IProgressListener progressMonitor)`
Get all objects referenced by the given objects.
`IPathsFromGCRootsComputer`
`getPathsFromGCRoots(int objectId, Map<IClass,Set<String>> excludeList)`
Get interactive computer for paths from GC roots to the given object.
`long`
`getRetainedHeapSize(int objectId)`
Get retained heap size for the given object.
`int[]`
`getRetainedSet(int[] objectIds, String[] fieldNames, IProgressListener listener)`
Get retained set of objects for the given fields at the given objects (excluding the given objects).
`int[]`
`getRetainedSet(int[] objectIds, ExcludedReferencesDescriptor[] excludedReferences, IProgressListener progressMonitor)`
Get retained set of objects for the given fields at the given objects (excluding the given objects).
`int[]`
`getRetainedSet(int[] objectIds, IProgressListener progressMonitor)`
Get retained set of objects for the given objects (including the given objects).
`RetainedSizeCache`
`getRetainedSizeCache()`
The cache to speed the finding of the retained size for each object.
`HashMapIntObject<HashMapIntObject<XGCRootInfo[]>>`
`getRootsPerThread()`
Gets the roots per thread from the variables on the stack frames.
`<A> A`
`getSnapshotAddons(Class<A> addon)`
Get additional JVM information, if available.
`XSnapshotInfo`
`getSnapshotInfo()`
Get info object describing the snapshot.
`IThreadStack`
`getThreadStack(int objectId)`
Get a the stack trace information for a given thread object, if thread stack information is available in this snapshot.
`int[]`
`getTopAncestorsInDominatorTree(int[] objectIds, IProgressListener listener)`
Get the top-ancestors in the dominator tree from the supplied objectIds.
`boolean`
`isArray(int objectId)`
Returns true if the object by this id is an array.
`boolean`
`isClass(int objectId)`
Returns true if the object by this id is a class.
`boolean`
`isClassLoader(int objectId)`
performance improved check if the object is a class loader
`boolean`
`isGCRoot(int objectId)`
Returns true if the object by this id is a garbage collection root.
`int`
`mapAddressToId(long objectAddress)`
Map object address (memory address where the object was stored) to object id (snapshot internal identity assigned during parsing).
`long`
`mapIdToAddress(int objectId)`
Map object id (snapshot internal identity assigned during parsing) to object address (memory address where the object was stored).
`static SnapshotImpl`
`readFromFile(File file, String prefix, IProgressListener listener)`
Read the snapshot from an already indexed dump.
`List<IClass>`
`resolveClassHierarchy(int classIndex)`
Finds the class and all its superclasses.
`void`
`setClassLoaderLabel(int objectId, String label)`
Associates a class loader with a name

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### readFromFile

public static SnapshotImpl readFromFile(File file, String prefix, IProgressListener listener) throws SnapshotException, IOException
Read the snapshot from an already indexed dump.

Parameters:
  `file` - the dump file
  `prefix` - the prefix of the path to find the index files
  `listener` - to report progress
Returns:
  the `ISnapshot`
Throws:
  `SnapshotException` - problem reading index files
  `IOException` - file I/O problem

### create

public static SnapshotImpl create(XSnapshotInfo snapshotInfo, String objectReaderUniqueIdentifier, IObjectReader heapObjectReader, HashMapIntObject<ClassImpl> classCache, HashMapIntObject<XGCRootInfo[]> roots, HashMapIntObject<HashMapIntObject<XGCRootInfo[]>> rootsPerThread, BitField arrayObjects, IndexManager indexManager, IProgressListener listener) throws IOException, SnapshotException
Create the snapshot after a fresh parse.

Parameters:
  `snapshotInfo` - the basic data about the snapshot
  `objectReaderUniqueIdentifier` - the type of the snapshot from the parser
  `heapObjectReader` - how to read objects from the file
  `classCache` - all the classes
  `roots` - all the GC roots
  `rootsPerThread` - the GC roots per thread
  `arrayObjects` - which objects are arrays
  `indexManager` - all the indexes
  `listener` - to report progress
Returns:
  the new `ISnapshot`
Throws:
  `IOException` - a file I/O problem
  `SnapshotException` - another problem

### getSnapshotInfo

public XSnapshotInfo getSnapshotInfo()
Description copied from interface: `ISnapshot`
Get info object describing the snapshot.

Performance: Fast - in memory.

Specified by:
  `getSnapshotInfo` in interface `ISnapshot`
Returns:
  info object describing the snapshot

### getGCRoots

public int[] getGCRoots() throws SnapshotException
Description copied from interface: `ISnapshot`
Get all GC roots.

A GC root is an object which doesn't need to be referenced to remain in the heap, e.g. all objects created in the thread stack frame.

Performance: Fast - in memory.

Specified by:
  `getGCRoots` in interface `ISnapshot`
Returns:
  int[] containing the objectIds of all GC roots
Throws:
  `SnapshotException` - should not normally occur

### getClasses

public Collection<IClass> getClasses() throws SnapshotException
Description copied from interface: `ISnapshot`
Get all classes.

The returned class is a snapshot representation of a Java class. It offers means to get to its name, class loader, fields, inheritance relationships and most importantly to all of its objects found in the heap.

Performance: Fast - in memory.

Specified by:
  `getClasses` in interface `ISnapshot`
Returns:
  collection of all classes
Throws:
  `SnapshotException` - should not normally occur

### getClassesByName

public Collection<IClass> getClassesByName(String name, boolean includeSubClasses) throws SnapshotException
Description copied from interface: `ISnapshot`
Get all classes by name.

This method returns you for one full class name all classes with this name. Usually you will get only one class back, but in the case of multiple class loaders which have loaded a class with the same name twice (or even the same class) you will get multiple snapshot class representations back as only the combination of class and class loader is unique, not the name alone.

Performance: Fast - in memory.

Specified by:
  `getClassesByName` in interface `ISnapshot`
Parameters:
  `name` - name for the class
  `includeSubClasses` - flag indicating whether or not to include also classes derived from matching classes (the name isn't taken into account for sub classes anymore)
Returns:
  collection of matching classes - current implementations can return null if there is no class found
Throws:
  `SnapshotException` - should not normally occur

### getClassesByName

public Collection<IClass> getClassesByName(Pattern namePattern, boolean includeSubClasses) throws SnapshotException
Description copied from interface: `ISnapshot`
Get all classes by name pattern.

This method returns you all classes with a name matching the regular expression pattern.

Performance: Fast - in memory, but needs iteration over all classes.

Specified by:
  `getClassesByName` in interface `ISnapshot`
Parameters:
  `namePattern` - name pattern for the class (regular expression)
  `includeSubClasses` - flag indicating whether or not to include also classes derived from matching classes (the name isn't taken into account for subclasses anymore)
Returns:
  collection of matching classes
Throws:
  `SnapshotException` - should not normally occur

### getHistogram

public Histogram getHistogram(IProgressListener listener) throws SnapshotException
Description copied from interface: `ISnapshot`
Get histogram for the whole snapshot.

This histogram lists all classes and class loaders and how many objects of the classes exist in the snapshot along with the memory consumption.

Performance: Fast - in memory.

Specified by:
  `getHistogram` in interface `ISnapshot`
Parameters:
  `listener` - progress listener informing about the current state of execution
Returns:
  histogram
Throws:
  `SnapshotException` - if there is a problem retrieving the information such as because of a damaged index.

### getHistogram

public Histogram getHistogram(int[] objectIds, IProgressListener progressMonitor) throws SnapshotException
Description copied from interface: `ISnapshot`
Get histogram for some specific objects - usually the result of other calls to the snapshot.

This histogram lists all classes and class loaders and how many objects of the classes exist among the given objects along with the memory consumption.

Performance: Fast to medium - on index (object id -> class id); depending on the number of objects.

Specified by:
  `getHistogram` in interface `ISnapshot`
Parameters:
  `objectIds` - object ids for which the histogram should be computed
  `progressMonitor` - progress listener informing about the current state of execution
Returns:
  histogram - current implementations can return null if the listener is cancelled
Throws:
  `SnapshotException` - if there is a problem retrieving the information such as because of a damaged index.

### getInboundRefererIds

public int[] getInboundRefererIds(int objectId) throws SnapshotException
Description copied from interface: `ISnapshot`
Get all objects referencing the given object.

This is the inverse of `ISnapshot.getOutboundReferentIds(int)`.

Performance: Relatively fast - single index operation.

Specified by:
  `getInboundRefererIds` in interface `ISnapshot`
Parameters:
  `objectId` - object which is referenced
Returns:
  objects referencing the given object
Throws:
  `SnapshotException` - should not normally occur

### getOutboundReferentIds

public int[] getOutboundReferentIds(int objectId) throws SnapshotException
Description copied from interface: `ISnapshot`
Get all objects referenced by the given object.

This shows the keep-alive relationship between objects and includes:

- a reference from an object to its type (class)
- reference fields in objects
- references in object arrays
- a references from a class to its class loader
- a reference from a class to its superclass
- static reference fields in class objects
- classes loaded by a class loader

This is the inverse of `ISnapshot.getInboundRefererIds(int)`.

Performance: Relatively fast - single index operation.

Specified by:
  `getOutboundReferentIds` in interface `ISnapshot`
Parameters:
  `objectId` - object which is referencing
Returns:
  objects referenced by the given object
Throws:
  `SnapshotException` - should not normally occur

### getInboundRefererIds

public int[] getInboundRefererIds(int[] objectIds, IProgressListener progressMonitor) throws SnapshotException
Description copied from interface: `ISnapshot`
Get all objects referencing the given objects.

Hint: This method is handy if you want to learn which classes reference a class. Therefore you would call this method with all objects of your class of interest and get a histogram out of the result.

This is the inverse of `ISnapshot.getOutboundReferentIds(int[], IProgressListener)`.

Performance: Fast to slow - on index; depending on the number of objects and the references.

Specified by:
  `getInboundRefererIds` in interface `ISnapshot`
Parameters:
  `objectIds` - objects which are referenced
  `progressMonitor` - progress listener informing about the current state of execution
Returns:
  objects referencing the given objects - current implementations can return null if the operation is cancelled
Throws:
  `SnapshotException` - should not normally occur

### getOutboundReferentIds

public int[] getOutboundReferentIds(int[] objectIds, IProgressListener progressMonitor) throws SnapshotException
Description copied from interface: `ISnapshot`
Get all objects referenced by the given objects.

Hint: This method is handy if you want to learn which classes are referenced by a class. Therefore you would call this method with all objects of your class of interest and get a histogram out of the result. This is the inverse of `ISnapshot.getInboundRefererIds(int[], IProgressListener)`.

Performance: Fast to slow - on index; depending on the number of objects and the references.

Specified by:
  `getOutboundReferentIds` in interface `ISnapshot`
Parameters:
  `objectIds` - objects which are referencing
  `progressMonitor` - progress listener informing about the current state of execution
Returns:
  objects referenced by the given objects - current implementations can return null if the operation is cancelled
Throws:
  `SnapshotException` - should not normally occur

### getPathsFromGCRoots

public IPathsFromGCRootsComputer getPathsFromGCRoots(int objectId, Map<IClass,Set<String>> excludeList) throws SnapshotException
Description copied from interface: `ISnapshot`
Get interactive computer for paths from GC roots to the given object.

Hint: This method is handy if you want to learn which objects are responsible for the given object to remain in memory. Since the snapshot implementation artificially creates references from the object to its class and from the class to its class loader you can even see why a class or class loaders remains in memory, i.e. which other objects hold references to objects of the class or class loader of interest.

Performance: Fast to slow - on index; depending on the number and length of GC root paths.

Specified by:
  `getPathsFromGCRoots` in interface `ISnapshot`
Parameters:
  `objectId` - object for which the GC root paths should be determined
  `excludeList` - a map specifying paths through which objects have to be avoided and not reported. Each entry in the map has the IClass as a key, and a Set<String> set, specifying which fields exactly from this key class have to be avoided. If for a key IClass the value (Set<String>) null is specified, then paths through any of the fields will be avoided
Returns:
  interactive computer for paths from GC roots to the given object
Throws:
  `SnapshotException` - if a problem occurs creating the paths computer

### getMultiplePathsFromGCRoots

public IMultiplePathsFromGCRootsComputer getMultiplePathsFromGCRoots(int[] objectIds, Map<IClass,Set<String>> excludeList) throws SnapshotException
Description copied from interface: `ISnapshot`
Returns an IMultiplePathsFromGCRootsComputer object, which can be used to calculate the shortest path from the GC roots to each of objects in the specified object set.

Specified by:
  `getMultiplePathsFromGCRoots` in interface `ISnapshot`
Parameters:
  `objectIds` - the IDs of the objects for which a shortest path has to be calculated
  `excludeList` - a map specifying paths through which objects have to be avoided and not reported. Each entry in the map has the IClass as a key, and a Set<String> set, specifying which fields exactly from this key class have to be avoided. If for a key IClass the value (Set<String>) null is specified, then paths through any of the fields will be avoided
Returns:
  IMultiplePathsFromGCRootsComputer The object which can be used to carry out the actual computation and
Throws:
  `SnapshotException` - if a problem occurs creating the paths computer

### getRetainedSet

public int[] getRetainedSet(int[] objectIds, IProgressListener progressMonitor) throws SnapshotException
Description copied from interface: `ISnapshot`
Get retained set of objects for the given objects (including the given objects).

The retained set includes the given objects and all objects which are lifetime-dependent on them, i.e. which would be garbage collected if the references to the given objects would be lost and the objects garbage collected.

Performance: Usually extremely slow - on index; depending on the number of objects and the references (deep).

Specified by:
  `getRetainedSet` in interface `ISnapshot`
Parameters:
  `objectIds` - objects on which the retained set should be determined
  `progressMonitor` - progress listener informing about the current state of execution
Returns:
  retained set of objects for the given objects
Throws:
  `SnapshotException` - if a problem occurs, for example if the operation was interrupted

### getRetainedSet

public int[] getRetainedSet(int[] objectIds, String[] fieldNames, IProgressListener listener) throws SnapshotException
Description copied from interface: `ISnapshot`
Get retained set of objects for the given fields at the given objects (excluding the given objects).

The retained set includes the objects referenced by the fields on the given objects and all objects which are lifetime-dependent on them, i.e. which would be garbage collected if the references at the given fields at the given objects would be nulled.

Performance: Usually extremely slow - on index; depending on the number of objects and the references (deep).

Specified by:
  `getRetainedSet` in interface `ISnapshot`
Parameters:
  `objectIds` - objects on which the retained set should be determined
  `fieldNames` - the names of the fields which could retain the objects
  `listener` - progress listener informing about the current state of execution
Returns:
  retained set of objects for the given objects
Throws:
  `SnapshotException` - if there was a problem, such as on cancellation

### getRetainedSet

public int[] getRetainedSet(int[] objectIds, ExcludedReferencesDescriptor[] excludedReferences, IProgressListener progressMonitor) throws SnapshotException
Description copied from interface: `ISnapshot`
Get retained set of objects for the given fields at the given objects (excluding the given objects).

The retained set includes the objects referenced by the fields on the given objects and all objects which are lifetime-dependent on them, i.e. which would be garbage collected if the references at the given fields at the given objects would be nulled.

Performance: Usually extremely slow - on index; depending on the number of objects and the references (deep).

Specified by:
  `getRetainedSet` in interface `ISnapshot`
Parameters:
  `objectIds` - objects on which the retained set should be determined
  `excludedReferences` - references which should not be followed
  `progressMonitor` - progress listener informing about the current state of execution
Returns:
  retained set of objects for the given objects
Throws:
  `SnapshotException` - if there was a problem, such as on cancellation

### getMinRetainedSize

public long getMinRetainedSize(int[] objectIds, IProgressListener progressMonitor) throws UnsupportedOperationException, SnapshotException
Description copied from interface: `ISnapshot`
Calculate the minimum retained size for the given objects. Works much faster than getting the min. retained set by getMinRetainedSet() and calculating the size of the min. retained set.

Specified by:
  `getMinRetainedSize` in interface `ISnapshot`
Parameters:
  `objectIds` - objects on which the minimum retained set should be determined
  `progressMonitor` - progress listener informing about the current state of execution
Returns:
  the minimum retained set of objects for the given objects
Throws:
  `SnapshotException` - if there was a problem, such as on cancellation
  `UnsupportedOperationException`

### getMinRetainedSet

public int[] getMinRetainedSet(int[] objectIds, IProgressListener progressMonitor) throws UnsupportedOperationException, SnapshotException
Description copied from interface: `ISnapshot`
Calculate the minimum retained set of objects for the given objects (including the given objects).

The minimum retained set includes the given objects and the union of the retained sets for each of the given objects (see getRetainedSet() for an explanation of a retained set). The union of the retained sets of the single objects is potentially smaller than the retained set of all of them, because some objects which are shared between two of the given objects may not appear in the retained set of any of the single objects, but will appear in the retained set if we take them as a whole. Because of it's faster performance the method is suitable to "mine" for a potentially big retained set (e.g. execute this method for all class loaders and see for potentially big ones). One can use the getRetainedSet() method afterwards to get the correct retained set.

Performance: Usually fast - for smaller sets this method is much faster than getRetainedSet

Specified by:
  `getMinRetainedSet` in interface `ISnapshot`
Parameters:
  `objectIds` - objects on which the minimum retained set should be determined
  `progressMonitor` - progress listener informing about the current state of execution
Returns:
  the minimum retained set of objects for the given objects
Throws:
  `SnapshotException` - if there was a problem, such as on cancellation
  `UnsupportedOperationException`

### getTopAncestorsInDominatorTree

public int[] getTopAncestorsInDominatorTree(int[] objectIds, IProgressListener listener) throws SnapshotException
Description copied from interface: `ISnapshot`
Get the top-ancestors in the dominator tree from the supplied objectIds. The result will be a list of objects (int[]), such that no object from the return list is parent of another object in the returned list. I.e. from a list of objects this method will return only the ones which are independent on one another. It is then correct to sum the retained sizes of the returned objects.

Specified by:
  `getTopAncestorsInDominatorTree` in interface `ISnapshot`
Parameters:
  `objectIds` - the objects for which the top-ancestors in the Dominator tree have to be found
  `listener` - progress listener informing about the current state of execution
Returns:
  int[] the objects which not in a parent/child relation in the dominator tree
Throws:
  `SnapshotException` - if the dominator tree has not been calculated

### calculateDominatorTree

public void calculateDominatorTree(IProgressListener listener) throws SnapshotException, IProgressListener.OperationCanceledException
Calculates the dominator tree after a parse

Parameters:
  `listener` - to report progress
Throws:
  `SnapshotException` - if a problem occurred
  `IProgressListener.OperationCanceledException` - if the calculation was cancelled by user via the listener

### getImmediateDominatedIds

public int[] getImmediateDominatedIds(int objectId) throws SnapshotException
Description copied from interface: `ISnapshot`
Get objects the given object directly dominates, i.e. the objects which are life-time dependent on the given object (not recursively, so just the directly dependent objects), i.e. the objects which would get collected as garbage if the given object would be gone from the heap.

Specified by:
  `getImmediateDominatedIds` in interface `ISnapshot`
Parameters:
  `objectId` - object for which the directly dominated objects should be returned
Returns:
  objects the given object directly dominates
Throws:
  `SnapshotException` - if the dominator tree has not been calculated

### getImmediateDominatorId

public int getImmediateDominatorId(int objectId) throws SnapshotException
Description copied from interface: `ISnapshot`
Get object which directly dominates the given object, i.e. the object which controls the life-time of the given object (not recursively, so just the directly controlling object), i.e. the object which would cause the given object to be collected as garbage if it would be gone from the heap.

Specified by:
  `getImmediateDominatorId` in interface `ISnapshot`
Parameters:
  `objectId` - object for which the directly dominated objects should be returned
Returns:
  Object id of the dominator. -1 if the object is dominated by the root of the dominator tree.
Throws:
  `SnapshotException` - if the dominator tree has not been calculated

### getDominatorsOf

public DominatorsSummary getDominatorsOf(int[] objectIds, Pattern excludePattern, IProgressListener progressListener) throws SnapshotException
Description copied from interface: `ISnapshot`
Get a summary of the dominators for all the given objects. The summary can be viewed on grouped by classes or class loaders

If an exclude pattern is provided, instead of returning the immediate dominator right away, its class name will be checked against the exclude pattern. If it matches the pattern, the dominator of this dominator will be taken and checked, and so on ... until a dominator not matching the pattern is found or the dominator tree root is reached.

Specified by:
  `getDominatorsOf` in interface `ISnapshot`
Parameters:
  `objectIds` - the objects for which we want the dominator summary (e.g. all objects of a given class)
  `excludePattern` - An exclude pattern. Domminators whose class name matches the pattern will be omitted and their dominator will be taken
  `progressListener` - progress listener informing about the current state of execution
Returns:
  DominatorsSummary the returned DominatorSummary contains the summary of the dominators grouped by classes or class loaders
Throws:
  `SnapshotException` - if the dominator tree has not been calculated

### getObject

public IObject getObject(int objectId) throws SnapshotException
Description copied from interface: `ISnapshot`
Get object abstracting the real Java Object from the heap dump identified by the given id.

Performance: Relatively fast - single index operation.

Specified by:
  `getObject` in interface `ISnapshot`
Parameters:
  `objectId` - id of object you want a convenient object abstraction for
Returns:
  object abstracting the real Java Object from the heap dump identified by the given id
Throws:
  `SnapshotException` - if there is a problem, such as perhaps an invalid objectId

### getGCRootInfo

public GCRootInfo[] getGCRootInfo(int objectId) throws SnapshotException
Description copied from interface: `ISnapshot`
Get the GC root info for an object. If the provided object is not a GC root, then null will be returned; otherwise, a GCRootInfo[]. An object can be a GC root for more than one reason and the returned array will contain one instance of GCRootInfo for each of the reasons (e.g. one GCRootInfo for every thread where an object is a java local variable)

Performance: Fast - in memory.

Specified by:
  `getGCRootInfo` in interface `ISnapshot`
Parameters:
  `objectId` - id of object you want the GC root info for
Returns:
  null if this object is no GC root or GCRootInfo[] if it is
Throws:
  `SnapshotException` - on an unexpected problem

### getClassOf

public IClass getClassOf(int objectId) throws SnapshotException
Description copied from interface: `ISnapshot`
Get object abstracting the real Java Class this object was an instance of in the heap dump identified by the given id.

Performance: Relatively fast - single index operation.

Specified by:
  `getClassOf` in interface `ISnapshot`
Parameters:
  `objectId` - id of object you want the convenient class abstraction for
Returns:
  object abstracting the real Java Class this object was an instance of in the heap dump identified by the given id
Throws:
  `SnapshotException` - if there is an unexpected problem

### mapIdToAddress

public long mapIdToAddress(int objectId) throws SnapshotException
Description copied from interface: `ISnapshot`
Map object id (snapshot internal identity assigned during parsing) to object address (memory address where the object was stored).

Performance: Fast - in memory.

Specified by:
  `mapIdToAddress` in interface `ISnapshot`
Parameters:
  `objectId` - id of object you want the address for
Returns:
  object address address of object with that id
Throws:
  `SnapshotException` - shouldn't normally happen as often a `RuntimeException` would be thrown if the object ID is invalid.

### getHeapSize

public long getHeapSize(int objectId) throws SnapshotException
Description copied from interface: `ISnapshot`
Get heap size for just the given object. new long[Integer.MAX_VALUE] is bigger than Integer.MAX_VALUE bytes, so this method now returns a long

Performance: Usually fast - in memory for non-array objects and single index operation for array objects.

Specified by:
  `getHeapSize` in interface `ISnapshot`
Parameters:
  `objectId` - id of object for which you want the heap size for
Returns:
  heap size for the given object.
Throws:
  `SnapshotException` - on an unexpected problem

### getHeapSize

public long getHeapSize(int[] objectIds) throws UnsupportedOperationException, SnapshotException
Description copied from interface: `ISnapshot`
Get the total shallow heap size for a set of objects.

Performance: Relatively fast - using this method to calculate the total size of a set of objects is much faster than iterating over the ids and calling getHeapSize for each single object

Specified by:
  `getHeapSize` in interface `ISnapshot`
Parameters:
  `objectIds` - ids of the objects for which you want the heap size for
Returns:
  total heap size for the given object set
Throws:
  `SnapshotException` - on an unexpected problem
  `UnsupportedOperationException`

### calculateMinRetainedHeapSizeForClasses

public void calculateMinRetainedHeapSizeForClasses(IProgressListener listener) throws SnapshotException
Calculate for each class an approximation for the retained size of all instances of that class.

Parameters:
  `listener` - for reporting progress
Throws:
  `SnapshotException` - if there is a problem

### getRetainedHeapSize

public long getRetainedHeapSize(int objectId) throws SnapshotException
Description copied from interface: `ISnapshot`
Get retained heap size for the given object.

The retained heap size is the memory which would be freed if all references to the given object would be released. It is extracted from the dominator tree and isn't available if the dominator tree isn't available itself.

Performance: Relatively fast - single index operation.

Specified by:
  `getRetainedHeapSize` in interface `ISnapshot`
Parameters:
  `objectId` - id of object for which you want the retained heap size for
Returns:
  retained heap size for the given object or 0 if no dominator tree was calculated
Throws:
  `SnapshotException` - on an unexpected problem

### isArray

public boolean isArray(int objectId)
Description copied from interface: `ISnapshot`
Returns true if the object by this id is an array.

Performance: Very fast.

Specified by:
  `isArray` in interface `ISnapshot`
Parameters:
  `objectId` - id of object to test for being an array (and so an `IArray`).
Returns:
  true if it is an array

### isClass

public boolean isClass(int objectId)
Description copied from interface: `ISnapshot`
Returns true if the object by this id is a class.

Performance: Very fast.

Specified by:
  `isClass` in interface `ISnapshot`
Parameters:
  `objectId` - id of object to test for being a class (and so an `IClass`).
Returns:
  true if it is a class

### isGCRoot

public boolean isGCRoot(int objectId)
Description copied from interface: `ISnapshot`
Returns true if the object by this id is a garbage collection root.

Performance: Very fast.

Specified by:
  `isGCRoot` in interface `ISnapshot`
Parameters:
  `objectId` - id of object to test for being a GC root
Returns:
  true if it is a GC root

### mapAddressToId

public int mapAddressToId(long objectAddress) throws SnapshotException
Description copied from interface: `ISnapshot`
Map object address (memory address where the object was stored) to object id (snapshot internal identity assigned during parsing).

Performance: Fast - binary search in memory.

Specified by:
  `mapAddressToId` in interface `ISnapshot`
Parameters:
  `objectAddress` - address of object you want the id for
Returns:
  object id
Throws:
  `SnapshotException` - if the object address is not found.

### dispose

public void dispose()
Description copied from interface: `ISnapshot`
Dispose the whole snapshot.

Please call this method prior to dropping the last reference to the snapshot as this method ensures the proper return of all resources (e.g. main memory, file and socket handles...). After calling this method the snapshot can't be used anymore.

Specified by:
  `dispose` in interface `ISnapshot`

### resolveClassHierarchy

public List<IClass> resolveClassHierarchy(int classIndex)
Finds the class and all its superclasses.

Parameters:
  `classIndex` - the class ID
Returns:
  all the classes

### isClassLoader

public boolean isClassLoader(int objectId)
performance improved check if the object is a class loader

Specified by:
  `isClassLoader` in interface `ISnapshot`
Parameters:
  `objectId` - id of object to test for being a class loader (and so an `IClassLoader`).
Returns:
  true if it is a class

### getClassLoaderLabel

public String getClassLoaderLabel(int objectId)
Finds the name associated with a class loader.

Parameters:
  `objectId` - the class loader
Returns:
  the name

### setClassLoaderLabel

public void setClassLoaderLabel(int objectId, String label)
Associates a class loader with a name

Parameters:
  `objectId` - the class loader
  `label` - the name

### getIndexManager

public IndexManager getIndexManager()
Gets all the indexes for the snapshot.

Returns:
  the manager of the indexes

### getHeapObjectReader

public IObjectReader getHeapObjectReader()
Gets the reader for the particular snapshot type to read individual objects.

Returns:
  the reader

### getRetainedSizeCache

public RetainedSizeCache getRetainedSizeCache()
The cache to speed the finding of the retained size for each object.

Returns:
  the cache

### getRootsPerThread

public HashMapIntObject<HashMapIntObject<XGCRootInfo[]>> getRootsPerThread()
Gets the roots per thread from the variables on the stack frames.

Returns:
  a map between the thread ID and the GC root information

### getSnapshotAddons

public <A> A getSnapshotAddons(Class<A> addon) throws SnapshotException
Get additional JVM information, if available.

A known type is `UnreachableObjectsHistogram`. Extra information can be obtained from an implementation of `IObjectReader.getAddon(Class)`.

Specified by:
  `getSnapshotAddons` in interface `ISnapshot`
Type Parameters:
  `A` - the type of the result
Parameters:
  `addon` - the type of the data. For example, `UnreachableObjectsHistogram`.class
Returns:
  the extra data
Throws:
  `SnapshotException` - if there is a problem retrieving the information

### getThreadStack

public IThreadStack getThreadStack(int objectId) throws SnapshotException
Description copied from interface: `ISnapshot`
Get a the stack trace information for a given thread object, if thread stack information is available in this snapshot.

Specified by:
  `getThreadStack` in interface `ISnapshot`
Parameters:
  `objectId` - the object ID of the thread
Returns:
  IThreadStack - an object representing the call stack of the thread. Returns null if no info is available for the object, or no stack info is available at all
Throws:
  `SnapshotException` - if there is a problem retrieving the information