|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jrockit.memleak.util.MemLeakAdapter
public class MemLeakAdapter
Adapter to simplify implementation of IMemLeak.
FIXME: All unimplemented methods should throw
UnsupportedOperationException.
FIXME: Make abstract? If so, easier to
forget adding new IMemLeak methods.
FIXME: Some of the comments below should probably be included in the contract
of the IMemLeak interface.
| Field Summary | |
|---|---|
protected static int[] |
EMPTY_INT_ARRAY
Shared empty int array used instead of null. |
protected java.util.Map<java.lang.Object,java.lang.Object> |
metaData
Map for storing static meta data, as well as keys for dynamic meta data. |
| Fields inherited from interface com.jrockit.memleak.IMemLeak |
|---|
FOREVER, META_IGNORED_REPLY_BYTES, META_KNOWN_KEYS, META_READ_BYTES, META_SERVER_PORT, META_SHORT_PROTOCOL_NAME, OBJECT_ID_INVALID, OBJECT_ID_NULL, UNLIMITED_DEPTH, UNLIMITED_INSTANCES, UNLIMITED_SIZE |
| Constructor Summary | |
|---|---|
MemLeakAdapter()
|
|
| Method Summary | ||
|---|---|---|
void |
deleteAllObjectIds()
Delete all object IDs. |
|
void |
deleteObjectId(int objectId)
Delete the given object ID. |
|
void |
deleteObjectId(IObjectSpecifier objectSpec)
FIXME: Fix comments, rename to dropRef() or similar. |
|
IResult<java.lang.Void> |
deleteObjectIds(int... objectIds)
Delete the object IDs in objectIds. |
|
void |
destroy()
Destroy the MemLeak. |
|
void |
disableAllocTraces()
Stop sending allocation traces. |
|
void |
doFullGC()
Cause a full Garbage Collect to happen on the server. |
|
void |
enableAllocTracesForClass(ITypeSpecifier type,
int bufferSize,
int interval,
AllocTraceCallback callback)
Enable traces for allocations of a certain type. |
|
void |
enableAllocTracesForClass(java.lang.String type,
int bufferSize,
int interval,
AllocTraceCallback callback)
Enable traces for allocations of a certain type. |
|
int |
getAllocTraceFrequency()
Get the current allocation trace report interval. |
|
IResult<IValue[]> |
getArrayData(IObjectSpecifier objectSpec,
int from,
int len)
Get the data from an array. |
|
int |
getArrayLength(IObjectSpecifier objectSpec)
Get the length of an array. |
|
IClassRef[] |
getClasses(ITypeSpecifier type,
Policy policy)
Requires Feature.CLASS_IDS. |
|
IClassRef[] |
getClasses(java.lang.String className,
Policy policy)
Requires Feature.CLASS_IDS. |
|
IClassInfo |
getClassInfo(IClassRef classRef)
Requires Feature.CLASS_NAME_OF_OBJECT. |
|
java.util.Set<Feature> |
getFeatures()
|
|
IResult<IFieldValue[]> |
getFieldValues(IObjectSpecifier objectSpec)
Get values and names for all fields in the object identified by objectSpec. |
|
IHeapHistogram |
getHeapHistogram()
Get a histogram of the heap. |
|
double |
getHistogramCutoff()
Get the cutoff point for types in the heap histograms. |
|
ITruncatable<IRelationshipInfo> |
getInstanceRelationships(ITypeSpecifier fromType,
ITypeSpecifier toType,
int maxRelations,
long stopAt,
int maxMillis)
Get all instances of fromType that points to instances of
toType. |
|
ITruncatable<IRelationshipInfo> |
getInstanceRelationships(java.lang.String fromType,
java.lang.String toType,
int maxRelations,
long stopAt,
int maxMillis)
Get all instances of fromType that points to instances of
toType. |
|
ITruncatable<IObjectInfo> |
getInstances(IClassRef classRef,
int maxInstances)
Requires Feature.INSTANCES_OF_TYPE. |
|
IInstanceReferrers |
getInstancesPointingTo(IObjectSpecifier objectSpec,
Policy policy)
Find all instances pointing to this object id. |
|
IResult<LimitedNumber> |
getKeepAliveSizeOf(IObjectSpecifier objectSpec,
long stopAt)
Get the total size of all objects held on to by this object (the transitive closure). |
|
ITruncatable<IArraySizeInfo> |
getLargestArrays(ITypeSpecifier type)
Get the 10 largest arrays on the heap. |
|
ITruncatable<IArraySizeInfo> |
getLargestArrays(java.lang.String type)
Get the 10 largest arrays on the heap. |
|
ITypeHeapInfo<IClassInfo> |
getLastTypeHeapInfo(IClassInfo classInfo,
Policy policy)
|
|
ITypeHeapInfo<?> |
getLastTypeHeapInfo(java.lang.String refType,
Policy policy)
|
|
java.lang.Object |
getMetaData(java.lang.Object key)
Obtain meta data for this connection. |
|
IResult<IObjectInfo> |
getObjectInfo(IObjectSpecifier objectSpec)
Requires Feature.CLASS_NAME_OF_OBJECT. |
|
ITruncatable<IInstanceReferrers> |
getPathPointingTo(IObjectSpecifier objectSpec,
int maxDepth,
int maxMillis)
Find a path from a GC root to the object denoted by objectSpec. |
|
|
getService(java.lang.Class<S> interfaceClass)
Return the service interface of type interfaceClass, if supported. |
|
IResult<IFieldValue[]> |
getStaticFields(IClassRef classRef)
Get values and names for all static fields in the class identified by classRef. |
|
IPointToTypeInfo[] |
getTypesPointingTo(ITypeSpecifier type,
Policy policy)
Find which types contain references to another type. |
|
IPointToTypeInfo[] |
getTypesPointingTo(java.lang.String type,
Policy policy)
Find which types contain references to another type. |
|
boolean |
hasFeatures(Feature... features)
|
|
boolean |
isAllocTracesEnabled()
Check if allocation traces are already enabled. |
|
boolean |
isConnected()
Returns true if we're connected to a (JRockit) server, false otherwise. |
|
boolean |
isTrendAnalysisEnabled()
Check whether trend analysis is enabled on the server. |
|
void |
pollAllocationTraces()
If allocation traces is enabled, poll the buffer on the server for any traces not yet sent to the client. |
|
boolean |
pollDiscardedObjects()
If supported, poll the server for objects (and classes) that have been garbage collected. |
|
void |
setAllocTraceFrequency(int reportInterval)
Changes the number of allocations that has to occur before an allocation trace will be reported. |
|
void |
setDisconnectCallback(DisconnectCallback disconnectCallback)
Sets the callback called if we're disconnected because communication with the server fails. |
|
void |
setHistogramCutoff(double histogramCutoff)
Set the cutoff point for types in the heap histograms (applicable both to getHeapHistogram and setTrendAnalysisEnabled). |
|
void |
setTrendAnalysisCallback(TrendAnalysisCallback cb)
Sets the callback that will be called, with the latest trend analysis, for each Garbage Collect that occurs when trend analysis is enabled. |
|
void |
setTrendAnalysisEnabled(boolean enabled)
Enable or disable trend analysis. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final int[] EMPTY_INT_ARRAY
protected java.util.Map<java.lang.Object,java.lang.Object> metaData
| Constructor Detail |
|---|
public MemLeakAdapter()
| Method Detail |
|---|
public void deleteObjectId(IObjectSpecifier objectSpec)
throws SpiException
IMemLeak
Requires Feature.DELETE_OBJECT_ID.
deleteObjectId in interface IMemLeakobjectSpec - an object specifier
SpiException
public void deleteObjectId(int objectId)
throws SpiException
IMemLeak
Requires Feature.DELETE_OBJECT_ID.
deleteObjectId in interface IMemLeakobjectId - an object ID
SpiExceptionpublic IResult<java.lang.Void> deleteObjectIds(int... objectIds)
IMemLeakobjectIds. Every object (or class)
ID returned from the other methods must be deleted exactly once. Once
deleted, an ID may be reused at any time.
Requires Feature.DELETE_OBJECT_ID.
deleteObjectIds in interface IMemLeakobjectIds - an array of object IDs
IResult whose get() method
will return null
public void deleteAllObjectIds()
throws SpiException
IMemLeak
Requires Feature.DELETE_ALL_OBJECT_IDS.
deleteAllObjectIds in interface IMemLeakSpiExceptionpublic boolean pollDiscardedObjects()
IMemLeakINotificationService listeners will be notified with IObjectInfos and IClassInfos for any GC:d objects.
This will also prevent those infos from being reachable from this SPI.
pollDiscardedObjects in interface IMemLeak
public void destroy()
throws java.io.IOException
IMemLeak
destroy in interface IMemLeakjava.io.IOException
public void disableAllocTraces()
throws SpiException
IMemLeak
Requires Feature.ALLOCATION_TRACES to actually do anything.
disableAllocTraces in interface IMemLeakSpiException
public void doFullGC()
throws SpiException
IMemLeak
Requires Feature.GC_TRIGGER to actually do anything.
doFullGC in interface IMemLeakSpiException
public final void enableAllocTracesForClass(java.lang.String type,
int bufferSize,
int interval,
AllocTraceCallback callback)
throws java.lang.IllegalStateException,
SpiException
IMemLeak
Requires Feature.ALLOCATION_TRACES.
enableAllocTracesForClass in interface IMemLeaktype - the type to look for. The type should be in VM format, i.e.
dots should be converted to slashes. java.lang.String ->
java/lang/String.bufferSize - how many different traces that should be collected on the
server before sending them over.interval - initial report interval - only every interval
allocation is looked at. This can later be changed by calling
setAllocTraceFrequency(int).callback - callback that receives the traces.
java.lang.IllegalStateException - if allocation traces is already enabled.
SpiExceptionIMemLeak.setAllocTraceFrequency(int)
public void enableAllocTracesForClass(ITypeSpecifier type,
int bufferSize,
int interval,
AllocTraceCallback callback)
throws java.lang.IllegalStateException,
SpiException
IMemLeak
Requires Feature.ALLOCATION_TRACES.
enableAllocTracesForClass in interface IMemLeaktype - specifier of the type to look for.bufferSize - how many different traces that should be collected on the
server before sending them over.interval - initial report interval - only every interval
allocation is looked at. This can later be changed by calling
setAllocTraceFrequency(int).callback - callback that receives the traces.
java.lang.IllegalStateException - if allocation traces is already enabled.
SpiExceptionIMemLeak.setAllocTraceFrequency(int)
public int getAllocTraceFrequency()
throws SpiException
IMemLeak
Requires Feature.ALLOCATION_TRACES for the return value to be of
any significance.
getAllocTraceFrequency in interface IMemLeakSpiException
public IResult<IValue[]> getArrayData(IObjectSpecifier objectSpec,
int from,
int len)
IMemLeak
getArrayData in interface IMemLeakobjectSpec - the arrayfrom - starting indexlen - how many elements to fetch
IResult whose IResult.get() either will return
an array of IValues representing the array elements, or
throw an exception.
public int getArrayLength(IObjectSpecifier objectSpec)
throws GarbageCollectedException,
SpiException
IMemLeak
getArrayLength in interface IMemLeakobjectSpec - the array
GarbageCollectedException
SpiExceptionpublic IResult<IFieldValue[]> getFieldValues(IObjectSpecifier objectSpec)
IMemLeak
getFieldValues in interface IMemLeakobjectSpec - an object specifier
IResult whose get() method
either will return an array of IFieldValues representing
the fields, or throw an exception.public IResult<IFieldValue[]> getStaticFields(IClassRef classRef)
IMemLeak
getStaticFields in interface IMemLeakclassRef - a class reference
IResult whose get() method
either will return an array of IFieldValues representing
the static fields, or throw an exception.
public IHeapHistogram getHeapHistogram()
throws SpiException
IMemLeak
getHeapHistogram in interface IMemLeakSpiExceptionpublic double getHistogramCutoff()
IMemLeak
getHistogramCutoff in interface IMemLeakIMemLeak.setHistogramCutoff(double)
public final ITruncatable<IRelationshipInfo> getInstanceRelationships(java.lang.String fromType,
java.lang.String toType,
int maxRelations,
long stopAt,
int maxMillis)
throws OperationException,
SpiException
IMemLeakfromType that points to instances of
toType.
The returned array will be no larger than maxRelations (it
may be smaller if there are fewer relations).
The returned array will be sorted on the keep-alive-size. This means that if keep-alive-sizes are calculated, and maxRelations is also set, only the instances with the highest keep-alive-size will be returned.
If stopAt is >= 0 the maximum keep-alive-size reported in
each IRelationshipInfo will be stopAt (this is to
limit the amount of objects traversed to find the size). Specifying zero
will effectively disable the keep-alive-size calculation, and the array
will effectively be unsorted.
If stopAt is IMemLeak.UNLIMITED_SIZE, there is no max for
keep-alive-size, which means the actual keep-alive-size will be returned.
getInstanceRelationships in interface IMemLeakmaxRelations - maximum number of relations to return. To return all
relations, use IMemLeak.UNLIMITED_INSTANCES (this can possibly
return a very large array).stopAt - the limit in bytes for keep alive size calculation, see abovemaxMillis - specifies the maximum amount of time (in milliseconds) the
server should spend completing the request. If more time has
elapsed the server will stop processing the request and return
the data as it is at that time. A value of IMemLeak.FOREVER
means infinite time.
ITruncatable with IRelationshipInfos on all
instances of fromType that points to instances of
toType.
OperationException
SpiExceptionIMemLeak.getKeepAliveSizeOf(IObjectSpecifier, long)
public ITruncatable<IRelationshipInfo> getInstanceRelationships(ITypeSpecifier fromType,
ITypeSpecifier toType,
int maxRelations,
long stopAt,
int maxMillis)
throws OperationException,
SpiException
IMemLeakfromType that points to instances of
toType.
The returned array will be no larger than maxRelations (it
may be smaller if there are fewer relations).
The returned array will be sorted on the keep-alive-size. This means that if keep-alive-sizes are calculated, and maxRelations is also set, only the instances with the highest keep-alive-size will be returned.
If stopAt is >= 0 the maximum keep-alive-size reported in
each IRelationshipInfo will be stopAt (this is to
limit the amount of objects traversed to find the size). Specifying zero
will effectively disable the keep-alive-size calculation, and the array
will effectively be unsorted.
If stopAt is IMemLeak.UNLIMITED_SIZE, there is no max for
keep-alive-size, which means the actual keep-alive-size will be returned.
getInstanceRelationships in interface IMemLeakmaxRelations - maximum number of relations to return. To return all
relations, use IMemLeak.UNLIMITED_INSTANCES (this can possibly
return a very large array).stopAt - the limit in bytes for keep alive size calculation, see abovemaxMillis - specifies the maximum amount of time (in milliseconds) the
server should spend completing the request. If more time has
elapsed the server will stop processing the request and return
the data as it is at that time. A value of IMemLeak.FOREVER
means infinite time.
ITruncatable with IRelationshipInfos on all
instances of fromType that points to instances of
toType.
OperationException
SpiExceptionIMemLeak.getKeepAliveSizeOf(IObjectSpecifier, long)
public IInstanceReferrers getInstancesPointingTo(IObjectSpecifier objectSpec,
Policy policy)
throws GarbageCollectedException,
SpiException
IMemLeakIInstanceReferrers.getThreadRoots() are not accurate but
a best guess, considering what is on the stack.
Note that null may be returned, if the policy allows it.
getInstancesPointingTo in interface IMemLeakobjectSpec - an object specifierpolicy - the policy to use
GarbageCollectedException
SpiException
public ITruncatable<IInstanceReferrers> getPathPointingTo(IObjectSpecifier objectSpec,
int maxDepth,
int maxMillis)
throws GarbageCollectedException,
OperationException,
SpiException
IMemLeakobjectSpec. Note that maxDepth is interpreted
in such a way that if there's any root at most this many steps away, a
root will always be returned. However, roots further away may still be
reported due to implementation details. Perhaps minDepth or simply depth
would be a better parameter name.
Requires Feature.INSTANCE_PATHS_TO_ROOT.
getPathPointingTo in interface IMemLeakobjectSpec - the object to find a root formaxDepth - the maximum number of backward steps that will be taken to
find a root, use IMemLeak.UNLIMITED_DEPTH for no limitmaxMillis - the maximum time in milliseconds to spend finding a root, not
including any time required by garbage collection, use
IMemLeak.FOREVER for no limit
IObjectSpecifier.
GarbageCollectedException
OperationException
SpiException
public IResult<LimitedNumber> getKeepAliveSizeOf(IObjectSpecifier objectSpec,
long stopAt)
IMemLeakstopAt >= 0 than counting will
stop if the total size is larger than stopAt.
getKeepAliveSizeOf in interface IMemLeakobjectSpec - an object idstopAt - the limit in bytes for keep alive size calculation, see above
IResult whose get() method will
give the total size in bytes of all objects held on to by this
object, limited by stopAt.public final ITruncatable<IArraySizeInfo> getLargestArrays(java.lang.String type)
IMemLeakITruncatable.Reason.EMPTY_REPLY is returned. (Since no
classloader is specified, these last two cases are not easily
differentiated.) Non-array types may give a NotAnArrayException as
reason.
getLargestArrays in interface IMemLeaktype - the type of the arrays
ITruncatable with IArraySizeInfos on the
largest arrays or a reason of
ITruncatable.Reason.EMPTY_REPLY if the type isn't loadedpublic ITruncatable<IArraySizeInfo> getLargestArrays(ITypeSpecifier type)
IMemLeakITruncatable.Reason.EMPTY_REPLY is returned. (Since a class
loader may or may not be specified, these last two cases are not easily
differentiated.) Non-array types may give a NotAnArrayException as
reason.
getLargestArrays in interface IMemLeaktype - the type of the arrays
ITruncatable with IArraySizeInfos on the
largest arrays or a reason of
ITruncatable.Reason.EMPTY_REPLY if the type isn't loaded
public java.lang.Object getMetaData(java.lang.Object key)
throws SpiException
IMemLeak
getMetaData in interface IMemLeakkey - The kind of meta data to return
SpiExceptionpublic java.util.Set<Feature> getFeatures()
getFeatures in interface IMemLeakSet containing the Features this
IMemLeak instance supports.public boolean hasFeatures(Feature... features)
hasFeatures in interface IMemLeakpublic <S> S getService(java.lang.Class<S> interfaceClass)
IMemLeakFeatures, and future
versions of Memleak may unify these two concepts further.)
getService in interface IMemLeakS, or null if the service isn't
supported.
public final IPointToTypeInfo[] getTypesPointingTo(java.lang.String type,
Policy policy)
throws OperationException,
SpiException
IMemLeak
Note that null may be returned, if the policy allows it.
getTypesPointingTo in interface IMemLeaktype - the type to look forpolicy - the policy to use
OperationException
SpiException
public IPointToTypeInfo[] getTypesPointingTo(ITypeSpecifier type,
Policy policy)
throws GarbageCollectedException,
OperationException,
SpiException
IMemLeak
Note that null may be returned, if the policy allows it.
getTypesPointingTo in interface IMemLeaktype - the type to look forpolicy - the policy to use
GarbageCollectedException
OperationException
SpiException
public boolean isAllocTracesEnabled()
throws SpiException
IMemLeak
Requires Feature.ALLOCATION_TRACES to ever return true.
isAllocTracesEnabled in interface IMemLeakSpiExceptionpublic boolean isConnected()
IMemLeakImplementations that doesn't require any external state should probably return true here (always).
isConnected in interface IMemLeak
public boolean isTrendAnalysisEnabled()
throws SpiException
IMemLeak
Requires Feature.TREND_ANALYSIS to ever return true.
isTrendAnalysisEnabled in interface IMemLeakSpiException
public void pollAllocationTraces()
throws java.lang.IllegalStateException,
SpiException
IMemLeak
pollAllocationTraces in interface IMemLeakjava.lang.IllegalStateException
SpiException
public void setAllocTraceFrequency(int reportInterval)
throws SpiException
IMemLeakGathering every allocation trace is sometimes (most times) too expensive. By skipping a number of allocations before reporting, the cost will be reduced. For example, an interval value of 1 will report every allocation, 2 will report every other allocation, and 30 will report every 30th allocation.
Requires Feature.ALLOCATION_TRACES.
setAllocTraceFrequency in interface IMemLeakreportInterval - the number of allocations that has to occur before an
allocation trace will be reported
SpiExceptionpublic void setDisconnectCallback(DisconnectCallback disconnectCallback)
IMemLeakThis likely won't have any effect for implementations that doesn't require any external state.
setDisconnectCallback in interface IMemLeakdisconnectCallback - the callback that handles the exception that was thrown due to
the communication error.
public void setHistogramCutoff(double histogramCutoff)
throws java.lang.IllegalArgumentException
IMemLeak
setHistogramCutoff in interface IMemLeakhistogramCutoff - Which types to leave out of the histograms. 0 means including
all types, 0.05 means including types occupying more than 5
percent of the heap, and 1 effectively means disregarding all
types.
java.lang.IllegalArgumentException - if the cutoff is less than zero or larger than 1.IMemLeak.setTrendAnalysisEnabled(boolean),
IMemLeak.getHeapHistogram()
public void setTrendAnalysisCallback(TrendAnalysisCallback cb)
throws SpiException
IMemLeak
This likely won't have any effect without Feature.TREND_ANALYSIS.
setTrendAnalysisCallback in interface IMemLeakcb - the callback
SpiException
public void setTrendAnalysisEnabled(boolean enabled)
throws java.lang.IllegalStateException,
SpiException
IMemLeak
Requires Feature.TREND_ANALYSIS.
setTrendAnalysisEnabled in interface IMemLeakjava.lang.IllegalStateException - if no callback has been registered
SpiExceptionpublic IResult<IObjectInfo> getObjectInfo(IObjectSpecifier objectSpec)
IMemLeakFeature.CLASS_NAME_OF_OBJECT.
getObjectInfo in interface IMemLeakobjectSpec - an IObjectSpecifier of an instance
IResult whose get() method
either will return an IObjectInfo representing the
instance, or throw an exception.
public IClassInfo getClassInfo(IClassRef classRef)
throws GarbageCollectedException,
SpiException
IMemLeakFeature.CLASS_NAME_OF_OBJECT.
getClassInfo in interface IMemLeakclassRef - an IClassRef of a class
IClassInfo of the class
GarbageCollectedException
SpiException
public final IClassRef[] getClasses(java.lang.String className,
Policy policy)
throws SpiException
IMemLeakFeature.CLASS_IDS.
Note that null may be returned, if the policy allows it.
getClasses in interface IMemLeakclassName - a class namepolicy - the policy to use
SpiException
public IClassRef[] getClasses(ITypeSpecifier type,
Policy policy)
throws SpiException
IMemLeakFeature.CLASS_IDS.
Note that null may be returned, if the policy allows it.
getClasses in interface IMemLeaktype - a type specifierpolicy - the policy to use
specifier, or
null according to policy
SpiException
public ITruncatable<IObjectInfo> getInstances(IClassRef classRef,
int maxInstances)
throws GarbageCollectedException,
SpiException
IMemLeakFeature.INSTANCES_OF_TYPE.
getInstances in interface IMemLeakclassRef - a type referencemaxInstances - the maximum number of instances to return, use
IMemLeak.UNLIMITED_INSTANCES to return all instances
ITruncatable with IObjectInfos of all instances
of classRef
GarbageCollectedException - if the class designated by classRef has been
garbage collected.
SpiException
public ITypeHeapInfo<IClassInfo> getLastTypeHeapInfo(IClassInfo classInfo,
Policy policy)
getLastTypeHeapInfo in interface IMemLeakpolicy - a time stamp in milliseconds
public ITypeHeapInfo<?> getLastTypeHeapInfo(java.lang.String refType,
Policy policy)
getLastTypeHeapInfo in interface IMemLeakpolicy - a time stamp in milliseconds
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||