|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectTranslatableAnalyzer
com.ibm.dtfj.analyzer.base.SimpleAnalyzerBean
com.ibm.dtfj.analyzer.helpers.objectwrapper.ObjectFinder
public class ObjectFinder
Find and count instances of particular objects in the Java runtime
Attempts to scan the heap only once and to create a cache of "interesting" objects.
This bean tries to scan the heap only once and to create a cache of "interesting" objects, so that it can quickly find instances of these objects without having to re-scan the entire heap each time when looking for a different object.
We use a regular expression to determine which objects are deemed "interesting"
enough to be placed in the cache. That regular expression that is matched against the class name
of each object found while scanning the heap. If the class name matches, instances of that object
are cached; otherwise they are simply counted, but we don't keep a copy of each instance and thus
we cannot return any instances in a call to findObjects()
.
This allows the cache to be substantially smaller than the heap from which it was built, without much loss of useful information, since in practice, a large percentage of heap objects are usually various arrays and low-level Java library classes that we seldom want to lookup directly anyway.
In addition, the property cachedInstancesMax
sets a limit on the number of instances of any
one class that are kept in the cache. If there are more than cachedInstancesMax
instances of
one given class in the heap, any additional instances are not cached. A subsequent call to
findObjects()
for that class will simply return the first cachedInstancesMax
encountered.
By default, we cache 100 instances of each class that matches com/*, javax/* or org/*. This default can
be changed by invoking addCachingPattern
.
Constructor Summary | |
---|---|
ObjectFinder()
|
Method Summary | |
---|---|
void |
addCachingPattern(java.lang.String regex,
int maxInstances)
Add a pattern (regexp) of class names for which we will cache instances while scanning the heap, so that these instances can be subsequently found by a call to findObjects(). |
com.ibm.dtfj.java.JavaObject |
findObjectByObjectID(com.ibm.dtfj.image.ImagePointer id)
Given an object ID (address), find the corresponding JavaObjectt (if any). |
java.util.Set |
findObjects(com.ibm.dtfj.java.JavaClass cls,
int maxcount)
Find all the object instances of a given class identified by JavaClass |
java.util.Set |
findObjects(java.lang.String clsname,
int maxcount)
Find all the object instances of a given class identified by class name (across all classloaders) |
int |
getCachingPriority()
Force caching of this analyzer |
int |
getCountClassObjects()
|
int |
getCountDistinctClassesScanned()
|
int |
getCountInstancesCached()
|
int |
getCountInstancesScanned()
|
int |
getCountObjectArrays()
|
int |
getCountPrimitiveArrays()
|
int |
getCountSingleObjects()
|
static ObjectFinder |
getInstance(IAnalyzerContext context,
com.ibm.dtfj.java.JavaRuntime parent)
Find the ObjectFinder bean instance associated with a given parent JavaRuntime (create it if necessary) |
int |
getMaxInstancesForClass(com.ibm.dtfj.java.JavaClass cls)
Figure-out if we should be caching a particular class (by JavaClass) and how many instances to cache. |
int |
getMaxInstancesForClass(java.lang.String clsname)
Figure-out if we should be caching a particular class (by name) and how many instances to cache |
int |
getObjectCount(com.ibm.dtfj.java.JavaClass cls)
Return a count of all the object instances of a given class identified by JavaClass |
int |
getObjectCount(java.lang.String clsname)
Return a count of all the object instances of a given class identified by class name (across all classloaders) |
int |
getObjectCountIncludingSubclasses(com.ibm.dtfj.java.JavaClass cls)
Return a count of all instances of a given class or any of its subclasses, identified by JavaClass |
int |
getObjectCountIncludingSubclasses(java.lang.String clsname)
Return a count of all instances of a given class or any of its subclasses, identified by class name (across all classloaders) |
java.lang.String |
getShortDescription()
Return a short description of the analyzer purpose. |
java.lang.String |
getVersion()
Get version information for this analyser. |
boolean |
isPrimaryAnalyzer()
Some Analyzers are designed to perform analysis tasks and others are designed to perform supporting tasks such as wrapping a DTFJ object and providing extra information. |
int |
printObjectCount(IAnalysisReport out,
java.lang.String label,
java.lang.String clsname)
Print a count of all the object instances of a given class identified by class name (across all classloaders). |
int |
printObjectCountIncludingSubclasses(IAnalysisReport out,
java.lang.String label,
java.lang.String clsname)
Print a count of all instances of a given class or any of its subclasses, identified by class name (across all classloaders). |
void |
printOneClass(IAnalysisReport out,
java.lang.String clsname,
int maxcount)
Print all the object instances of a given class identified by class name (across all classloaders), as a segment of a report |
IAnalysisReport |
produceReport()
Generate a report which will be encapsulated in the IAnalysisReport object for later use by some formatter. |
void |
setParent(java.lang.Object parent)
Set the parent JavaRuntime underlying this analyzer bean. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ObjectFinder()
Method Detail |
---|
public java.lang.String getVersion()
IAnalyzerBase
getVersion
in interface IAnalyzerBase
getVersion
in class SimpleAnalyzerBean
IAnalyzerBase.getVersion()
public java.lang.String getShortDescription()
IAnalyzerBase
getShortDescription
in interface IAnalyzerBase
getShortDescription
in class SimpleAnalyzerBean
IAnalyzerBase.getShortDescription()
public boolean isPrimaryAnalyzer()
IAnalyzerBase
isPrimaryAnalyzer
in interface IAnalyzerBase
isPrimaryAnalyzer
in class SimpleAnalyzerBean
IAnalyzerBase.isPrimaryAnalyzer()
public static ObjectFinder getInstance(IAnalyzerContext context, com.ibm.dtfj.java.JavaRuntime parent)
context
- the AnalyzerContext in which to locate this bean instanceparent
- the parent JavaRuntime underlying this analyzer bean
public void setParent(java.lang.Object parent)
setParent
in interface IWrapper
setParent
in class SimpleAnalyzerBean
parent
- The parent object to set. Must be of type JavaRuntime.
compatible with the type of analyzer bean that receives itIWrapper.setParent(java.lang.Object)
public int getCachingPriority()
getCachingPriority
in interface IAnalyzerBase
getCachingPriority
in class SimpleAnalyzerBean
SimpleAnalyzerBean.getCachingPriority()
public java.util.Set findObjects(com.ibm.dtfj.java.JavaClass cls, int maxcount) throws com.ibm.dtfj.image.DTFJException
cls
- the JavaClass for which we want to find all instancesmaxcount
- the maximum number of objects to return, or 0 for all
com.ibm.dtfj.image.DTFJException
public int getObjectCount(com.ibm.dtfj.java.JavaClass cls) throws com.ibm.dtfj.image.DTFJException
cls
- the JavaClass for which we want to find all instances
com.ibm.dtfj.image.DTFJException
public int getObjectCountIncludingSubclasses(com.ibm.dtfj.java.JavaClass cls) throws com.ibm.dtfj.image.DTFJException
cls
- the JavaClass for which we want to count all instances
com.ibm.dtfj.image.DTFJException
public int getObjectCountIncludingSubclasses(java.lang.String clsname) throws com.ibm.dtfj.image.DTFJException
clsname
- the class name for which we want to count all instances
com.ibm.dtfj.image.DTFJException
public int printObjectCountIncludingSubclasses(IAnalysisReport out, java.lang.String label, java.lang.String clsname)
This method is provided purely as convenience when writing reports. One could also call getObjectCount() and print its return value explicitly (and handle any errors explicitly).
out
- a AnalysisReport object to which to write the outputlabel
- a name to use as title for the report entry showing the countclsname
- the class name for which we want to count all instances
public java.util.Set findObjects(java.lang.String clsname, int maxcount) throws com.ibm.dtfj.image.DTFJException
clsname
- the class name for which we want to find all instancesmaxcount
- the maximum number of objects to return, or 0 for all
com.ibm.dtfj.image.DTFJException
public com.ibm.dtfj.java.JavaObject findObjectByObjectID(com.ibm.dtfj.image.ImagePointer id) throws com.ibm.dtfj.image.DTFJException
id
- object ID of the desired JavaObject
com.ibm.dtfj.image.DTFJException
public void printOneClass(IAnalysisReport out, java.lang.String clsname, int maxcount)
out
- a AnalysisReport object to which to write the outputclsname
- the class name for which we want to find all instancesmaxcount
- the maximum number of objects to return, or 0 for allpublic int getObjectCount(java.lang.String clsname) throws com.ibm.dtfj.image.DTFJException
clsname
- the class name for which we want to count all instances
com.ibm.dtfj.image.DTFJException
public int printObjectCount(IAnalysisReport out, java.lang.String label, java.lang.String clsname)
This method is provided purely as convenience when writing reports. One could also call getObjectCount() and print its return value explicitly (and handle any errors explicitly).
out
- a AnalysisReport object to which to write the outputlabel
- a name to use as title for the report entry showing the countclsname
- the class name for which we want to count all instances
public void addCachingPattern(java.lang.String regex, int maxInstances)
This pattern is used to limit the number object instances that get cached when scanning to heap, to avoid caching hundreds of thousands of "uninteresting" objects.
The pattern added with this call is in addition to the built-in patterns always cached by this analyzer: com/*, javax/*, org/*
Note that adding a pattern after the analyzer has already been used to look-up objects, will have the effect of discarding any previous results of a heap scan, and triggering a new heap scan.
regex
- a string representing the pattern in regexp formatmaxInstances
- an integer representing the maximum number of instances to cache per classpublic int getMaxInstancesForClass(java.lang.String clsname)
clsname
- the class name
public int getMaxInstancesForClass(com.ibm.dtfj.java.JavaClass cls) throws com.ibm.dtfj.image.DTFJException
cls
- the JavaClass to check
com.ibm.dtfj.image.DTFJException
public int getCountClassObjects() throws com.ibm.dtfj.image.DTFJException
com.ibm.dtfj.image.DTFJException
public int getCountDistinctClassesScanned() throws com.ibm.dtfj.image.DTFJException
com.ibm.dtfj.image.DTFJException
public int getCountInstancesCached() throws com.ibm.dtfj.image.DTFJException
com.ibm.dtfj.image.DTFJException
public int getCountInstancesScanned() throws com.ibm.dtfj.image.DTFJException
com.ibm.dtfj.image.DTFJException
public int getCountObjectArrays() throws com.ibm.dtfj.image.DTFJException
com.ibm.dtfj.image.DTFJException
public int getCountPrimitiveArrays() throws com.ibm.dtfj.image.DTFJException
com.ibm.dtfj.image.DTFJException
public int getCountSingleObjects() throws com.ibm.dtfj.image.DTFJException
com.ibm.dtfj.image.DTFJException
public IAnalysisReport produceReport()
IReport
produceReport
in interface IReport
produceReport
in class SimpleAnalyzerBean
IReport.produceReport()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |