com.jrockit.memleak.util
Class MemLeakAdapter

java.lang.Object
  extended by com.jrockit.memleak.util.MemLeakAdapter
All Implemented Interfaces:
IMemLeak
Direct Known Subclasses:
AbstractMemLeak

public class MemLeakAdapter
extends java.lang.Object
implements IMemLeak

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.

Author:
mpersson

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.
<S> S
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

EMPTY_INT_ARRAY

protected static final int[] EMPTY_INT_ARRAY
Shared empty int array used instead of null.


metaData

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.

Constructor Detail

MemLeakAdapter

public MemLeakAdapter()
Method Detail

deleteObjectId

public void deleteObjectId(IObjectSpecifier objectSpec)
                    throws SpiException
Description copied from interface: IMemLeak
FIXME: Fix comments, rename to dropRef() or similar. Delete the given object ID. 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.

Specified by:
deleteObjectId in interface IMemLeak
Parameters:
objectSpec - an object specifier
Throws:
SpiException

deleteObjectId

public void deleteObjectId(int objectId)
                    throws SpiException
Description copied from interface: IMemLeak
Delete the given object ID. 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.

Specified by:
deleteObjectId in interface IMemLeak
Parameters:
objectId - an object ID
Throws:
SpiException

deleteObjectIds

public IResult<java.lang.Void> deleteObjectIds(int... objectIds)
Description copied from interface: IMemLeak
Delete the object IDs in objectIds. 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.

Specified by:
deleteObjectIds in interface IMemLeak
Parameters:
objectIds - an array of object IDs
Returns:
An IResult whose get() method will return null

deleteAllObjectIds

public void deleteAllObjectIds()
                        throws SpiException
Description copied from interface: IMemLeak
Delete all object IDs. 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_ALL_OBJECT_IDS.

Specified by:
deleteAllObjectIds in interface IMemLeak
Throws:
SpiException

pollDiscardedObjects

public boolean pollDiscardedObjects()
Description copied from interface: IMemLeak
If supported, poll the server for objects (and classes) that have been garbage collected. All INotificationService 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.

Specified by:
pollDiscardedObjects in interface IMemLeak
Returns:
true if this operation is supported.

destroy

public void destroy()
             throws java.io.IOException
Description copied from interface: IMemLeak
Destroy the MemLeak. This will delete all object ids that have not yet been deleted. No calls to MemLeak are allowed after destroy is called.

Specified by:
destroy in interface IMemLeak
Throws:
java.io.IOException

disableAllocTraces

public void disableAllocTraces()
                        throws SpiException
Description copied from interface: IMemLeak
Stop sending allocation traces. This will cause methods that have been instrumented to revert back to the original code.

Requires Feature.ALLOCATION_TRACES to actually do anything.

Specified by:
disableAllocTraces in interface IMemLeak
Throws:
SpiException

doFullGC

public void doFullGC()
              throws SpiException
Description copied from interface: IMemLeak
Cause a full Garbage Collect to happen on the server. This will clear out objects referenced only by soft references.

Requires Feature.GC_TRIGGER to actually do anything.

Specified by:
doFullGC in interface IMemLeak
Throws:
SpiException

enableAllocTracesForClass

public final void enableAllocTracesForClass(java.lang.String type,
                                            int bufferSize,
                                            int interval,
                                            AllocTraceCallback callback)
                                     throws java.lang.IllegalStateException,
                                            SpiException
Description copied from interface: IMemLeak
Enable traces for allocations of a certain type. This will cause all methods that allocate objects of this type to be recompiled with instrumentation. Traces can only be enabled for one type at a time.

Requires Feature.ALLOCATION_TRACES.

Specified by:
enableAllocTracesForClass in interface IMemLeak
Parameters:
type - 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.
Throws:
java.lang.IllegalStateException - if allocation traces is already enabled.
SpiException
See Also:
IMemLeak.setAllocTraceFrequency(int)

enableAllocTracesForClass

public void enableAllocTracesForClass(ITypeSpecifier type,
                                      int bufferSize,
                                      int interval,
                                      AllocTraceCallback callback)
                               throws java.lang.IllegalStateException,
                                      SpiException
Description copied from interface: IMemLeak
Enable traces for allocations of a certain type. This will cause all methods that allocate objects of this type to be recompiled with instrumentation. Traces can only be enabled for one type at a time.

Requires Feature.ALLOCATION_TRACES.

Specified by:
enableAllocTracesForClass in interface IMemLeak
Parameters:
type - 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.
Throws:
java.lang.IllegalStateException - if allocation traces is already enabled.
SpiException
See Also:
IMemLeak.setAllocTraceFrequency(int)

getAllocTraceFrequency

public int getAllocTraceFrequency()
                           throws SpiException
Description copied from interface: IMemLeak
Get the current allocation trace report interval.

Requires Feature.ALLOCATION_TRACES for the return value to be of any significance.

Specified by:
getAllocTraceFrequency in interface IMemLeak
Returns:
the number of allocations that has to occur before an allocation trace will be reported
Throws:
SpiException

getArrayData

public IResult<IValue[]> getArrayData(IObjectSpecifier objectSpec,
                                      int from,
                                      int len)
Description copied from interface: IMemLeak
Get the data from an array.

Specified by:
getArrayData in interface IMemLeak
Parameters:
objectSpec - the array
from - starting index
len - how many elements to fetch
Returns:
An IResult whose IResult.get() either will return an array of IValues representing the array elements, or throw an exception.

getArrayLength

public int getArrayLength(IObjectSpecifier objectSpec)
                   throws GarbageCollectedException,
                          SpiException
Description copied from interface: IMemLeak
Get the length of an array.

Specified by:
getArrayLength in interface IMemLeak
Parameters:
objectSpec - the array
Returns:
the length of the array
Throws:
GarbageCollectedException
SpiException

getFieldValues

public IResult<IFieldValue[]> getFieldValues(IObjectSpecifier objectSpec)
Description copied from interface: IMemLeak
Get values and names for all fields in the object identified by objectSpec.

Specified by:
getFieldValues in interface IMemLeak
Parameters:
objectSpec - an object specifier
Returns:
An IResult whose get() method either will return an array of IFieldValues representing the fields, or throw an exception.

getStaticFields

public IResult<IFieldValue[]> getStaticFields(IClassRef classRef)
Description copied from interface: IMemLeak
Get values and names for all static fields in the class identified by classRef.

Specified by:
getStaticFields in interface IMemLeak
Parameters:
classRef - a class reference
Returns:
An IResult whose get() method either will return an array of IFieldValues representing the static fields, or throw an exception.

getHeapHistogram

public IHeapHistogram getHeapHistogram()
                                throws SpiException
Description copied from interface: IMemLeak
Get a histogram of the heap. Sum of size and instances for each type.

Specified by:
getHeapHistogram in interface IMemLeak
Returns:
a histogram of the heap
Throws:
SpiException

getHistogramCutoff

public double getHistogramCutoff()
Description copied from interface: IMemLeak
Get the cutoff point for types in the heap histograms.

Specified by:
getHistogramCutoff in interface IMemLeak
Returns:
the current cutoff point
See Also:
IMemLeak.setHistogramCutoff(double)

getInstanceRelationships

public final ITruncatable<IRelationshipInfo> getInstanceRelationships(java.lang.String fromType,
                                                                      java.lang.String toType,
                                                                      int maxRelations,
                                                                      long stopAt,
                                                                      int maxMillis)
                                                               throws OperationException,
                                                                      SpiException
Description copied from interface: IMemLeak
Get all instances of fromType 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.

Specified by:
getInstanceRelationships in interface IMemLeak
maxRelations - 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 above
maxMillis - 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.
Returns:
an ITruncatable with IRelationshipInfos on all instances of fromType that points to instances of toType.
Throws:
OperationException
SpiException
See Also:
IMemLeak.getKeepAliveSizeOf(IObjectSpecifier, long)

getInstanceRelationships

public ITruncatable<IRelationshipInfo> getInstanceRelationships(ITypeSpecifier fromType,
                                                                ITypeSpecifier toType,
                                                                int maxRelations,
                                                                long stopAt,
                                                                int maxMillis)
                                                         throws OperationException,
                                                                SpiException
Description copied from interface: IMemLeak
Get all instances of fromType 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.

Specified by:
getInstanceRelationships in interface IMemLeak
maxRelations - 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 above
maxMillis - 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.
Returns:
an ITruncatable with IRelationshipInfos on all instances of fromType that points to instances of toType.
Throws:
OperationException
SpiException
See Also:
IMemLeak.getKeepAliveSizeOf(IObjectSpecifier, long)

getInstancesPointingTo

public IInstanceReferrers getInstancesPointingTo(IObjectSpecifier objectSpec,
                                                 Policy policy)
                                          throws GarbageCollectedException,
                                                 SpiException
Description copied from interface: IMemLeak
Find all instances pointing to this object id. The methods in the returned IInstanceReferrers.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.

Specified by:
getInstancesPointingTo in interface IMemLeak
Parameters:
objectSpec - an object specifier
policy - the policy to use
Returns:
information about all instances pointing to this object, or null according to policy
Throws:
GarbageCollectedException
SpiException

getPathPointingTo

public ITruncatable<IInstanceReferrers> getPathPointingTo(IObjectSpecifier objectSpec,
                                                          int maxDepth,
                                                          int maxMillis)
                                                   throws GarbageCollectedException,
                                                          OperationException,
                                                          SpiException
Description copied from interface: IMemLeak
Find a path from a GC root to the object denoted by objectSpec. 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.

Specified by:
getPathPointingTo in interface IMemLeak
Parameters:
objectSpec - the object to find a root for
maxDepth - the maximum number of backward steps that will be taken to find a root, use IMemLeak.UNLIMITED_DEPTH for no limit
maxMillis - the maximum time in milliseconds to spend finding a root, not including any time required by garbage collection, use IMemLeak.FOREVER for no limit
Returns:
an array of IInstanceReferrers denoting a path from a root to the given IObjectSpecifier.
Throws:
GarbageCollectedException
OperationException
SpiException

getKeepAliveSizeOf

public IResult<LimitedNumber> getKeepAliveSizeOf(IObjectSpecifier objectSpec,
                                                 long stopAt)
Description copied from interface: IMemLeak
Get the total size of all objects held on to by this object (the transitive closure). If stopAt >= 0 than counting will stop if the total size is larger than stopAt.

Specified by:
getKeepAliveSizeOf in interface IMemLeak
Parameters:
objectSpec - an object id
stopAt - the limit in bytes for keep alive size calculation, see above
Returns:
An IResult whose get() method will give the total size in bytes of all objects held on to by this object, limited by stopAt.

getLargestArrays

public final ITruncatable<IArraySizeInfo> getLargestArrays(java.lang.String type)
Description copied from interface: IMemLeak
Get the 10 largest arrays on the heap. If the given array type does not have any instances, but is loaded, a zero length array is returned. If the type isn't loaded, or doesn't exist, a reason of ITruncatable.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.

Specified by:
getLargestArrays in interface IMemLeak
Parameters:
type - the type of the arrays
Returns:
an ITruncatable with IArraySizeInfos on the largest arrays or a reason of ITruncatable.Reason.EMPTY_REPLY if the type isn't loaded

getLargestArrays

public ITruncatable<IArraySizeInfo> getLargestArrays(ITypeSpecifier type)
Description copied from interface: IMemLeak
Get the 10 largest arrays on the heap. If the given array type does not have any instances, but is loaded, a zero length array is returned. If the type isn't loaded, or doesn't exist, a reason of ITruncatable.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.

Specified by:
getLargestArrays in interface IMemLeak
Parameters:
type - the type of the arrays
Returns:
an ITruncatable with IArraySizeInfos on the largest arrays or a reason of ITruncatable.Reason.EMPTY_REPLY if the type isn't loaded

getMetaData

public java.lang.Object getMetaData(java.lang.Object key)
                             throws SpiException
Description copied from interface: IMemLeak
Obtain meta data for this connection. The keys are either META_* constants of this interface or implementation specific. Implementations unaware of the given key (including META_* constants) should return null. Used mainly for diagnostic purposes.

Specified by:
getMetaData in interface IMemLeak
Parameters:
key - The kind of meta data to return
Returns:
the meta data of that kind or null
Throws:
SpiException

getFeatures

public java.util.Set<Feature> getFeatures()
Specified by:
getFeatures in interface IMemLeak
Returns:
a Set containing the Features this IMemLeak instance supports.

hasFeatures

public boolean hasFeatures(Feature... features)
Specified by:
hasFeatures in interface IMemLeak
Returns:
true iff all the given features are supported by this instance.

getService

public <S> S getService(java.lang.Class<S> interfaceClass)
Description copied from interface: IMemLeak
Return the service interface of type interfaceClass, if supported. (Service interfaces roughly corresponds to Features, and future versions of Memleak may unify these two concepts further.)

Specified by:
getService in interface IMemLeak
Returns:
an instance of S, or null if the service isn't supported.

getTypesPointingTo

public final IPointToTypeInfo[] getTypesPointingTo(java.lang.String type,
                                                   Policy policy)
                                            throws OperationException,
                                                   SpiException
Description copied from interface: IMemLeak
Find which types contain references to another type. For example: "which types contain references to [C?".

Note that null may be returned, if the policy allows it.

Specified by:
getTypesPointingTo in interface IMemLeak
Parameters:
type - the type to look for
policy - the policy to use
Returns:
information about which types contain references to type , or null according to policy
Throws:
OperationException
SpiException

getTypesPointingTo

public IPointToTypeInfo[] getTypesPointingTo(ITypeSpecifier type,
                                             Policy policy)
                                      throws GarbageCollectedException,
                                             OperationException,
                                             SpiException
Description copied from interface: IMemLeak
Find which types contain references to another type. For example: "which types contain references to [C?".

Note that null may be returned, if the policy allows it.

Specified by:
getTypesPointingTo in interface IMemLeak
Parameters:
type - the type to look for
policy - the policy to use
Returns:
information about which types contain references to type , or null according to policy
Throws:
GarbageCollectedException
OperationException
SpiException

isAllocTracesEnabled

public boolean isAllocTracesEnabled()
                             throws SpiException
Description copied from interface: IMemLeak
Check if allocation traces are already enabled.

Requires Feature.ALLOCATION_TRACES to ever return true.

Specified by:
isAllocTracesEnabled in interface IMemLeak
Returns:
whether allocation traces are already enabled
Throws:
SpiException

isConnected

public boolean isConnected()
Description copied from interface: IMemLeak
Returns true if we're connected to a (JRockit) server, false otherwise.

Implementations that doesn't require any external state should probably return true here (always).

Specified by:
isConnected in interface IMemLeak
Returns:
true or false

isTrendAnalysisEnabled

public boolean isTrendAnalysisEnabled()
                               throws SpiException
Description copied from interface: IMemLeak
Check whether trend analysis is enabled on the server.

Requires Feature.TREND_ANALYSIS to ever return true.

Specified by:
isTrendAnalysisEnabled in interface IMemLeak
Returns:
whether trend anlysis is enabled on the server
Throws:
SpiException

pollAllocationTraces

public void pollAllocationTraces()
                          throws java.lang.IllegalStateException,
                                 SpiException
Description copied from interface: IMemLeak
If allocation traces is enabled, poll the buffer on the server for any traces not yet sent to the client. The callback set with enableAllocTracesForClass will be called. This will empty the buffer.

Specified by:
pollAllocationTraces in interface IMemLeak
Throws:
java.lang.IllegalStateException
SpiException

setAllocTraceFrequency

public void setAllocTraceFrequency(int reportInterval)
                            throws SpiException
Description copied from interface: IMemLeak
Changes the number of allocations that has to occur before an allocation trace will be reported.

Gathering 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.

Specified by:
setAllocTraceFrequency in interface IMemLeak
Parameters:
reportInterval - the number of allocations that has to occur before an allocation trace will be reported
Throws:
SpiException

setDisconnectCallback

public void setDisconnectCallback(DisconnectCallback disconnectCallback)
Description copied from interface: IMemLeak
Sets the callback called if we're disconnected because communication with the server fails. Note that this callback is only called when the communication fails. Normal, client initiated, termination of the communication will not result in the disconnect callback being called.

This likely won't have any effect for implementations that doesn't require any external state.

Specified by:
setDisconnectCallback in interface IMemLeak
Parameters:
disconnectCallback - the callback that handles the exception that was thrown due to the communication error.

setHistogramCutoff

public void setHistogramCutoff(double histogramCutoff)
                        throws java.lang.IllegalArgumentException
Description copied from interface: IMemLeak
Set the cutoff point for types in the heap histograms (applicable both to getHeapHistogram and setTrendAnalysisEnabled). Types which occupy less than this much of the total heap will not be shown in the histograms. 1.0 cuts off everything. 0 doesn't cut off anything.

Specified by:
setHistogramCutoff in interface IMemLeak
Parameters:
histogramCutoff - 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.
Throws:
java.lang.IllegalArgumentException - if the cutoff is less than zero or larger than 1.
See Also:
IMemLeak.setTrendAnalysisEnabled(boolean), IMemLeak.getHeapHistogram()

setTrendAnalysisCallback

public void setTrendAnalysisCallback(TrendAnalysisCallback cb)
                              throws SpiException
Description copied from interface: IMemLeak
Sets the callback that will be called, with the latest trend analysis, for each Garbage Collect that occurs when trend analysis is enabled.

This likely won't have any effect without Feature.TREND_ANALYSIS.

Specified by:
setTrendAnalysisCallback in interface IMemLeak
Parameters:
cb - the callback
Throws:
SpiException

setTrendAnalysisEnabled

public void setTrendAnalysisEnabled(boolean enabled)
                             throws java.lang.IllegalStateException,
                                    SpiException
Description copied from interface: IMemLeak
Enable or disable trend analysis.

Requires Feature.TREND_ANALYSIS.

Specified by:
setTrendAnalysisEnabled in interface IMemLeak
Throws:
java.lang.IllegalStateException - if no callback has been registered
SpiException

getObjectInfo

public IResult<IObjectInfo> getObjectInfo(IObjectSpecifier objectSpec)
Description copied from interface: IMemLeak
Requires Feature.CLASS_NAME_OF_OBJECT.

Specified by:
getObjectInfo in interface IMemLeak
Parameters:
objectSpec - an IObjectSpecifier of an instance
Returns:
An IResult whose get() method either will return an IObjectInfo representing the instance, or throw an exception.

getClassInfo

public IClassInfo getClassInfo(IClassRef classRef)
                        throws GarbageCollectedException,
                               SpiException
Description copied from interface: IMemLeak
Requires Feature.CLASS_NAME_OF_OBJECT.

Specified by:
getClassInfo in interface IMemLeak
Parameters:
classRef - an IClassRef of a class
Returns:
the IClassInfo of the class
Throws:
GarbageCollectedException
SpiException

getClasses

public final IClassRef[] getClasses(java.lang.String className,
                                    Policy policy)
                             throws SpiException
Description copied from interface: IMemLeak
Requires Feature.CLASS_IDS.

Note that null may be returned, if the policy allows it.

Specified by:
getClasses in interface IMemLeak
Parameters:
className - a class name
policy - the policy to use
Returns:
Class ID:s of all classes with name className in all class loaders, or null according to policy
Throws:
SpiException

getClasses

public IClassRef[] getClasses(ITypeSpecifier type,
                              Policy policy)
                       throws SpiException
Description copied from interface: IMemLeak
Requires Feature.CLASS_IDS.

Note that null may be returned, if the policy allows it.

Specified by:
getClasses in interface IMemLeak
Parameters:
type - a type specifier
policy - the policy to use
Returns:
Class ID:s of all classes specified by specifier, or null according to policy
Throws:
SpiException

getInstances

public ITruncatable<IObjectInfo> getInstances(IClassRef classRef,
                                              int maxInstances)
                                       throws GarbageCollectedException,
                                              SpiException
Description copied from interface: IMemLeak
Requires Feature.INSTANCES_OF_TYPE.

Specified by:
getInstances in interface IMemLeak
Parameters:
classRef - a type reference
maxInstances - the maximum number of instances to return, use IMemLeak.UNLIMITED_INSTANCES to return all instances
Returns:
an ITruncatable with IObjectInfos of all instances of classRef
Throws:
GarbageCollectedException - if the class designated by classRef has been garbage collected.
SpiException

getLastTypeHeapInfo

public ITypeHeapInfo<IClassInfo> getLastTypeHeapInfo(IClassInfo classInfo,
                                                     Policy policy)
Specified by:
getLastTypeHeapInfo in interface IMemLeak
policy - a time stamp in milliseconds
Returns:
the last received heap info, or null if none has been received.

getLastTypeHeapInfo

public ITypeHeapInfo<?> getLastTypeHeapInfo(java.lang.String refType,
                                            Policy policy)
Specified by:
getLastTypeHeapInfo in interface IMemLeak
policy - a time stamp in milliseconds
Returns:
the last received heap info, or null if none has been received.


Copyright © 1999, 2011, Oracle and/or its affiliates. All rights reserved.