|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.mat.parser.internal.SnapshotImpl
public final class SnapshotImpl
Method Summary | ||
---|---|---|
void |
calculateDominatorTree(IProgressListener listener)
|
|
static SnapshotImpl |
create(XSnapshotInfo snapshotInfo,
java.lang.String objectReaderUniqueIdentifier,
IObjectReader heapObjectReader,
HashMapIntObject<ClassImpl> classCache,
HashMapIntObject<XGCRootInfo[]> roots,
HashMapIntObject<HashMapIntObject<XGCRootInfo[]>> rootsPerThread,
BitField arrayObjects,
IndexManager indexManager,
IProgressListener listener)
|
|
void |
dispose()
Dispose the whole snapshot. |
|
java.util.Collection<IClass> |
getClasses()
Get all classes. |
|
java.util.Collection<IClass> |
getClassesByName(java.util.regex.Pattern namePattern,
boolean includeSubClasses)
Get all classes by name pattern. |
|
java.util.Collection<IClass> |
getClassesByName(java.lang.String name,
boolean includeSubClasses)
Get all classes by name. |
|
java.lang.String |
getClassLoaderLabel(int objectId)
|
|
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,
java.util.regex.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()
|
|
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()
|
|
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,
java.util.Map<IClass,java.util.Set<java.lang.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,
java.util.Map<IClass,java.util.Set<java.lang.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,
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). |
|
int[] |
getRetainedSet(int[] objectIds,
java.lang.String[] fieldNames,
IProgressListener listener)
Get retained set of objects for the given fields at the given objects (excluding the given objects). |
|
RetainedSizeCache |
getRetainedSizeCache()
|
|
HashMapIntObject<HashMapIntObject<XGCRootInfo[]>> |
getRootsPerThread()
|
|
|
getSnapshotAddons(java.lang.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(java.io.File file,
java.lang.String prefix,
IProgressListener listener)
|
|
java.util.List<IClass> |
resolveClassHierarchy(int classIndex)
|
|
void |
setClassLoaderLabel(int objectId,
java.lang.String label)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static SnapshotImpl readFromFile(java.io.File file, java.lang.String prefix, IProgressListener listener) throws SnapshotException, java.io.IOException
SnapshotException
java.io.IOException
public static SnapshotImpl create(XSnapshotInfo snapshotInfo, java.lang.String objectReaderUniqueIdentifier, IObjectReader heapObjectReader, HashMapIntObject<ClassImpl> classCache, HashMapIntObject<XGCRootInfo[]> roots, HashMapIntObject<HashMapIntObject<XGCRootInfo[]>> rootsPerThread, BitField arrayObjects, IndexManager indexManager, IProgressListener listener) throws java.io.IOException, SnapshotException
java.io.IOException
SnapshotException
public XSnapshotInfo getSnapshotInfo()
ISnapshot
Performance: Fast - in memory.
getSnapshotInfo
in interface ISnapshot
public int[] getGCRoots() throws SnapshotException
ISnapshot
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.
getGCRoots
in interface ISnapshot
SnapshotException
public java.util.Collection<IClass> getClasses() throws SnapshotException
ISnapshot
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.
getClasses
in interface ISnapshot
SnapshotException
public java.util.Collection<IClass> getClassesByName(java.lang.String name, boolean includeSubClasses) throws SnapshotException
ISnapshot
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.
getClassesByName
in interface ISnapshot
name
- name for the classincludeSubClasses
- flag indicating whether or not to include also classes derived
from matching classes (the name isn't taken into account for
sub classes anymore)
SnapshotException
public java.util.Collection<IClass> getClassesByName(java.util.regex.Pattern namePattern, boolean includeSubClasses) throws SnapshotException
ISnapshot
This method returns you all classes with a name matching the regular expression pattern.
Performance: Fast - in memory, but needs iteration over all classes.
getClassesByName
in interface ISnapshot
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
sub classes anymore)
SnapshotException
public Histogram getHistogram(IProgressListener listener) throws SnapshotException
ISnapshot
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.
getHistogram
in interface ISnapshot
listener
- progress listener informing about the current state of
execution
SnapshotException
public Histogram getHistogram(int[] objectIds, IProgressListener progressMonitor) throws SnapshotException
ISnapshot
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.
getHistogram
in interface ISnapshot
objectIds
- object ids for which the histogram should be computedprogressMonitor
- progress listener informing about the current state of
execution
SnapshotException
public int[] getInboundRefererIds(int objectId) throws SnapshotException
ISnapshot
This is the inverse of {@link #getOutboundReferentIds(int[], IProgressListener).
Performance: Relatively fast - single index operation.
getInboundRefererIds
in interface ISnapshot
objectId
- object which is referenced
SnapshotException
public int[] getOutboundReferentIds(int objectId) throws SnapshotException
ISnapshot
This shows the keep-alive relationship between objects and includes:
Performance: Relatively fast - single index operation.
getOutboundReferentIds
in interface ISnapshot
objectId
- object which is referencing
SnapshotException
public int[] getInboundRefererIds(int[] objectIds, IProgressListener progressMonitor) throws SnapshotException
ISnapshot
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.
Performance: Fast to slow - on index; depending on the number of objects and the references.
getInboundRefererIds
in interface ISnapshot
objectIds
- objects which are referencedprogressMonitor
- progress listener informing about the current state of
execution
SnapshotException
public int[] getOutboundReferentIds(int[] objectIds, IProgressListener progressMonitor) throws SnapshotException
ISnapshot
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.
Performance: Fast to slow - on index; depending on the number of objects and the references.
getOutboundReferentIds
in interface ISnapshot
objectIds
- objects which are referencingprogressMonitor
- progress listener informing about the current state of
execution
SnapshotException
public IPathsFromGCRootsComputer getPathsFromGCRoots(int objectId, java.util.Map<IClass,java.util.Set<java.lang.String>> excludeList) throws SnapshotException
ISnapshot
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.
getPathsFromGCRoots
in interface ISnapshot
objectId
- object for which the GC root paths should be determinedexcludeList
- 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 SetSnapshotException
public IMultiplePathsFromGCRootsComputer getMultiplePathsFromGCRoots(int[] objectIds, java.util.Map<IClass,java.util.Set<java.lang.String>> excludeList) throws SnapshotException
ISnapshot
getMultiplePathsFromGCRoots
in interface ISnapshot
objectIds
- the IDs of the objects for which a shortest path has to be
calculatedexcludeList
- 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 SetSnapshotException
public int[] getRetainedSet(int[] objectIds, IProgressListener progressMonitor) throws SnapshotException
ISnapshot
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).
getRetainedSet
in interface ISnapshot
objectIds
- objects on which the retained set should be determinedprogressMonitor
- progress listener informing about the current state of
execution
SnapshotException
public int[] getRetainedSet(int[] objectIds, java.lang.String[] fieldNames, IProgressListener listener) throws SnapshotException
ISnapshot
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).
getRetainedSet
in interface ISnapshot
objectIds
- objects on which the retained set should be determinedlistener
- progress listener informing about the current state of
execution
SnapshotException
public int[] getRetainedSet(int[] objectIds, ExcludedReferencesDescriptor[] excludedReferences, IProgressListener progressMonitor) throws SnapshotException
ISnapshot
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).
getRetainedSet
in interface ISnapshot
objectIds
- objects on which the retained set should be determinedexcludedReferences
- references which should not be followedprogressMonitor
- progress listener informing about the current state of
execution
SnapshotException
public long getMinRetainedSize(int[] objectIds, IProgressListener progressMonitor) throws java.lang.UnsupportedOperationException, SnapshotException
ISnapshot
getMinRetainedSize
in interface ISnapshot
objectIds
- objects on which the minimum retained set should be determinedprogressMonitor
- progress listener informing about the current state of
execution
SnapshotException
java.lang.UnsupportedOperationException
public int[] getMinRetainedSet(int[] objectIds, IProgressListener progressMonitor) throws java.lang.UnsupportedOperationException, SnapshotException
ISnapshot
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
getMinRetainedSet
in interface ISnapshot
objectIds
- objects on which the minimum retained set should be determinedprogressMonitor
- progress listener informing about the current state of
execution
SnapshotException
java.lang.UnsupportedOperationException
public int[] getTopAncestorsInDominatorTree(int[] objectIds, IProgressListener listener) throws SnapshotException
ISnapshot
getTopAncestorsInDominatorTree
in interface ISnapshot
objectIds
- the objects for which the top-ancestors in the Dominator tree
have to be foundlistener
- progress listener informing about the current state of
execution
SnapshotException
public void calculateDominatorTree(IProgressListener listener) throws SnapshotException, IProgressListener.OperationCanceledException
SnapshotException
IProgressListener.OperationCanceledException
public int[] getImmediateDominatedIds(int objectId) throws SnapshotException
ISnapshot
getImmediateDominatedIds
in interface ISnapshot
objectId
- object for which the directly dominated objects should be
returned
SnapshotException
public int getImmediateDominatorId(int objectId) throws SnapshotException
ISnapshot
getImmediateDominatorId
in interface ISnapshot
objectId
- object for which the directly dominated objects should be
returned
SnapshotException
public DominatorsSummary getDominatorsOf(int[] objectIds, java.util.regex.Pattern excludePattern, IProgressListener progressListener) throws SnapshotException
ISnapshot
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.
getDominatorsOf
in interface ISnapshot
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 takenprogressListener
- progress listener informing about the current state of
execution
SnapshotException
public IObject getObject(int objectId) throws SnapshotException
ISnapshot
Performance: Relatively fast - single index operation.
getObject
in interface ISnapshot
objectId
- id of object you want a convenient object abstraction for
SnapshotException
public GCRootInfo[] getGCRootInfo(int objectId) throws SnapshotException
ISnapshot
Performance: Fast - in memory.
getGCRootInfo
in interface ISnapshot
objectId
- id of object you want the GC root info for
SnapshotException
public IClass getClassOf(int objectId) throws SnapshotException
ISnapshot
Performance: Relatively fast - single index operation.
getClassOf
in interface ISnapshot
objectId
- id of object you want the convenient class abstraction for
SnapshotException
public long mapIdToAddress(int objectId) throws SnapshotException
ISnapshot
Performance: Fast - in memory.
mapIdToAddress
in interface ISnapshot
objectId
- id of object you want the address for
SnapshotException
public long getHeapSize(int objectId) throws SnapshotException
ISnapshot
Performance: Usually fast - in memory for non-array objects and single index operation for array objects.
getHeapSize
in interface ISnapshot
objectId
- id of object for which you want the heap size for
SnapshotException
public long getHeapSize(int[] objectIds) throws java.lang.UnsupportedOperationException, SnapshotException
ISnapshot
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
getHeapSize
in interface ISnapshot
objectIds
- ids of the objects for which you want the heap size for
SnapshotException
java.lang.UnsupportedOperationException
public long getRetainedHeapSize(int objectId) throws SnapshotException
ISnapshot
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.
getRetainedHeapSize
in interface ISnapshot
objectId
- id of object for which you want the retained heap size for
SnapshotException
public boolean isArray(int objectId)
ISnapshot
Performance: Very fast.
isArray
in interface ISnapshot
public boolean isClass(int objectId)
ISnapshot
Performance: Very fast.
isClass
in interface ISnapshot
public boolean isGCRoot(int objectId)
ISnapshot
Performance: Very fast.
isGCRoot
in interface ISnapshot
public int mapAddressToId(long objectAddress) throws SnapshotException
ISnapshot
Performance: Fast - binary search in memory.
mapAddressToId
in interface ISnapshot
objectAddress
- address of object you want the id for
SnapshotException
public void dispose()
ISnapshot
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.
dispose
in interface ISnapshot
public java.util.List<IClass> resolveClassHierarchy(int classIndex)
public boolean isClassLoader(int objectId)
isClassLoader
in interface ISnapshot
public java.lang.String getClassLoaderLabel(int objectId)
public void setClassLoaderLabel(int objectId, java.lang.String label)
public IndexManager getIndexManager()
public IObjectReader getHeapObjectReader()
public RetainedSizeCache getRetainedSizeCache()
public HashMapIntObject<HashMapIntObject<XGCRootInfo[]>> getRootsPerThread()
public <A> A getSnapshotAddons(java.lang.Class<A> addon) throws SnapshotException
A known type is UnreachableObjectsHistogram
.
Extra information can be obtained from an implementation of IObjectReader.getAddon(Class)
.
getSnapshotAddons
in interface ISnapshot
the
- type of the data. For example, UnreachableObjectsHistogram
.class
SnapshotException
public IThreadStack getThreadStack(int objectId) throws SnapshotException
ISnapshot
getThreadStack
in interface ISnapshot
SnapshotException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |