|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IMemLeak
Public API for the memory leak detection system in JRockit.
Field Summary | |
---|---|
static int |
FOREVER
Used as timeout when no timeout is wanted. |
static java.lang.String |
META_IGNORED_REPLY_BYTES
Key for getMetaData(Object) to obtain the number of bytes that
was ignored or skipped while parsing replies, as a Long . |
static java.lang.String |
META_KNOWN_KEYS
Key for getMetaData(Object) to obtain a Collection of
all known keys. |
static java.lang.String |
META_READ_BYTES
Key for getMetaData(Object) to obtain the number of read bytes
as a Long . |
static java.lang.String |
META_SERVER_PORT
Key for getMetaData(Object) to obtain the server port as an
Integer . |
static java.lang.String |
META_SHORT_PROTOCOL_NAME
Key for getMetaData(Object) to obtain the protocol name as a
String . |
static int |
OBJECT_ID_INVALID
An object id that is invalid. |
static int |
OBJECT_ID_NULL
An object reference that is null gets this id. |
static int |
UNLIMITED_DEPTH
Used as maximum depth for path to root when wanting to go as far back as the implementation can handle. |
static int |
UNLIMITED_INSTANCES
Used as maximum number of instances/relations when all are wanted. |
static long |
UNLIMITED_SIZE
Used as maximum size in bytes, for example as keep-alive-size, when no limit is wanted. |
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 specifier,
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. |
Field Detail |
---|
static final int UNLIMITED_DEPTH
static final int UNLIMITED_INSTANCES
static final long UNLIMITED_SIZE
static final int FOREVER
static final int OBJECT_ID_INVALID
static final int OBJECT_ID_NULL
static final java.lang.String META_KNOWN_KEYS
getMetaData(Object)
to obtain a Collection
of
all known keys.
static final java.lang.String META_SHORT_PROTOCOL_NAME
getMetaData(Object)
to obtain the protocol name as a
String
.
static final java.lang.String META_SERVER_PORT
getMetaData(Object)
to obtain the server port as an
Integer
.
static final java.lang.String META_READ_BYTES
getMetaData(Object)
to obtain the number of read bytes
as a Long
.
static final java.lang.String META_IGNORED_REPLY_BYTES
getMetaData(Object)
to obtain the number of bytes that
was ignored or skipped while parsing replies, as a Long
. This is
mostly a debugging help to detect protocol implementation errors.
Method Detail |
---|
java.lang.Object getMetaData(java.lang.Object key) throws SpiException
key
- The kind of meta data to return
SpiException
java.util.Set<Feature> getFeatures()
Set
containing the Feature
s this
IMemLeak
instance supports.boolean hasFeatures(Feature... features)
features
-
<S> S getService(java.lang.Class<S> interfaceClass)
Feature
s, and future
versions of Memleak may unify these two concepts further.)
S
- interfaceClass
-
S
, or null if the service isn't
supported.void setTrendAnalysisCallback(TrendAnalysisCallback cb) throws SpiException
This likely won't have any effect without Feature.TREND_ANALYSIS
.
cb
- the callback
SpiException
void setTrendAnalysisEnabled(boolean enabled) throws java.lang.IllegalStateException, SpiException
Requires Feature.TREND_ANALYSIS
.
enabled
-
java.lang.IllegalStateException
- if no callback has been registered
SpiException
boolean isTrendAnalysisEnabled() throws SpiException
Requires Feature.TREND_ANALYSIS
to ever return true.
SpiException
IHeapHistogram getHeapHistogram() throws SpiException
SpiException
void setHistogramCutoff(double histogramCutoff) throws java.lang.IllegalArgumentException
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.
java.lang.IllegalArgumentException
- if the cutoff is less than zero or larger than 1.setTrendAnalysisEnabled(boolean)
,
getHeapHistogram()
double getHistogramCutoff()
setHistogramCutoff(double)
IPointToTypeInfo[] getTypesPointingTo(java.lang.String type, Policy policy) throws OperationException, SpiException
Note that null may be returned, if the policy
allows it.
type
- the type to look forpolicy
- the policy to use
OperationException
SpiException
IPointToTypeInfo[] getTypesPointingTo(ITypeSpecifier type, Policy policy) throws GarbageCollectedException, OperationException, SpiException
Note that null may be returned, if the policy
allows it.
type
- the type to look forpolicy
- the policy to use
GarbageCollectedException
OperationException
SpiException
ITruncatable<IArraySizeInfo> getLargestArrays(java.lang.String type)
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.
type
- the type of the arrays
ITruncatable
with IArraySizeInfo
s on the
largest arrays or a reason of
ITruncatable.Reason.EMPTY_REPLY
if the type isn't loadedITruncatable<IArraySizeInfo> getLargestArrays(ITypeSpecifier type)
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.
type
- the type of the arrays
ITruncatable
with IArraySizeInfo
s on the
largest arrays or a reason of
ITruncatable.Reason.EMPTY_REPLY
if the type isn't loadedIInstanceReferrers getInstancesPointingTo(IObjectSpecifier objectSpec, Policy policy) throws GarbageCollectedException, SpiException
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.
objectSpec
- an object specifierpolicy
- the policy to use
GarbageCollectedException
SpiException
ITruncatable<IInstanceReferrers> getPathPointingTo(IObjectSpecifier objectSpec, int maxDepth, int maxMillis) throws GarbageCollectedException, OperationException, SpiException
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
.
objectSpec
- the object to find a root formaxDepth
- the maximum number of backward steps that will be taken to
find a root, use UNLIMITED_DEPTH
for no limitmaxMillis
- the maximum time in milliseconds to spend finding a root, not
including any time required by garbage collection, use
FOREVER
for no limit
IObjectSpecifier
.
GarbageCollectedException
OperationException
SpiException
ITruncatable<IRelationshipInfo> getInstanceRelationships(java.lang.String fromType, java.lang.String toType, int maxRelations, long stopAt, int maxMillis) throws OperationException, SpiException
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 UNLIMITED_SIZE
, there is no max for
keep-alive-size, which means the actual keep-alive-size will be returned.
fromType
- toType
- maxRelations
- maximum number of relations to return. To return all
relations, use 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 FOREVER
means infinite time.
ITruncatable
with IRelationshipInfo
s on all
instances of fromType that points to instances of
toType.
OperationException
SpiException
getKeepAliveSizeOf(IObjectSpecifier, long)
ITruncatable<IRelationshipInfo> getInstanceRelationships(ITypeSpecifier fromType, ITypeSpecifier toType, int maxRelations, long stopAt, int maxMillis) throws OperationException, SpiException
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 UNLIMITED_SIZE
, there is no max for
keep-alive-size, which means the actual keep-alive-size will be returned.
fromType
- toType
- maxRelations
- maximum number of relations to return. To return all
relations, use 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 FOREVER
means infinite time.
ITruncatable
with IRelationshipInfo
s on all
instances of fromType that points to instances of
toType.
OperationException
SpiException
getKeepAliveSizeOf(IObjectSpecifier, long)
IResult<LimitedNumber> getKeepAliveSizeOf(IObjectSpecifier objectSpec, long stopAt)
stopAt
>= 0 than counting will
stop if the total size is larger than stopAt
.
objectSpec
- 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
.IResult<IFieldValue[]> getFieldValues(IObjectSpecifier objectSpec)
objectSpec
- an object specifier
IResult
whose get()
method
either will return an array of IFieldValue
s representing
the fields, or throw an exception.IResult<IFieldValue[]> getStaticFields(IClassRef classRef)
classRef
- a class reference
IResult
whose get()
method
either will return an array of IFieldValue
s representing
the static fields, or throw an exception.int getArrayLength(IObjectSpecifier objectSpec) throws GarbageCollectedException, SpiException
objectSpec
- the array
GarbageCollectedException
SpiException
IResult<IValue[]> getArrayData(IObjectSpecifier objectSpec, int from, int len)
objectSpec
- the arrayfrom
- starting indexlen
- how many elements to fetch
IResult
whose IResult.get()
either will return
an array of IValue
s representing the array elements, or
throw an exception.
java.lang.IllegalArgumentException
- if objectId is not valid
java.lang.IndexOutOfBoundsException
- if from and/or len are invalid valuesvoid enableAllocTracesForClass(java.lang.String type, int bufferSize, int interval, AllocTraceCallback callback) throws java.lang.IllegalStateException, SpiException
Requires Feature.ALLOCATION_TRACES
.
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.
java.lang.IllegalStateException
- if allocation traces is already enabled.
SpiException
setAllocTraceFrequency(int)
void enableAllocTracesForClass(ITypeSpecifier type, int bufferSize, int interval, AllocTraceCallback callback) throws java.lang.IllegalStateException, SpiException
Requires Feature.ALLOCATION_TRACES
.
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.
java.lang.IllegalStateException
- if allocation traces is already enabled.
SpiException
setAllocTraceFrequency(int)
void pollAllocationTraces() throws java.lang.IllegalStateException, SpiException
java.lang.IllegalStateException
SpiException
boolean isAllocTracesEnabled() throws SpiException
Requires Feature.ALLOCATION_TRACES
to ever return true.
SpiException
void disableAllocTraces() throws SpiException
Requires Feature.ALLOCATION_TRACES
to actually do anything.
SpiException
void setAllocTraceFrequency(int reportInterval) throws SpiException
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
.
reportInterval
- the number of allocations that has to occur before an
allocation trace will be reported
SpiException
int getAllocTraceFrequency() throws SpiException
Requires Feature.ALLOCATION_TRACES
for the return value to be of
any significance.
SpiException
void doFullGC() throws SpiException
Requires Feature.GC_TRIGGER
to actually do anything.
SpiException
void deleteObjectId(IObjectSpecifier objectSpec) throws SpiException
Requires Feature.DELETE_OBJECT_ID
.
objectSpec
- an object specifier
SpiException
void deleteObjectId(int objectId) throws SpiException
Requires Feature.DELETE_OBJECT_ID
.
objectId
- an object ID
SpiException
IResult<java.lang.Void> deleteObjectIds(int... objectIds)
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
.
objectIds
- an array of object IDs
IResult
whose get()
method
will return nullvoid deleteAllObjectIds() throws SpiException
Requires Feature.DELETE_ALL_OBJECT_IDS
.
SpiException
boolean pollDiscardedObjects()
INotificationService
listeners will be notified with IObjectInfo
s and IClassInfo
s for any GC:d objects.
This will also prevent those infos from being reachable from this SPI.
void destroy() throws java.io.IOException
java.io.IOException
void setDisconnectCallback(DisconnectCallback disconnectCallback)
This likely won't have any effect for implementations that doesn't require any external state.
disconnectCallback
- the callback that handles the exception that was thrown due to
the communication error.boolean isConnected()
Implementations that doesn't require any external state should probably return true here (always).
IResult<IObjectInfo> getObjectInfo(IObjectSpecifier objectSpec)
Feature.CLASS_NAME_OF_OBJECT
.
objectSpec
- an IObjectSpecifier
of an instance
IResult
whose get()
method
either will return an IObjectInfo
representing the
instance, or throw an exception.IClassInfo getClassInfo(IClassRef classRef) throws GarbageCollectedException, SpiException
Feature.CLASS_NAME_OF_OBJECT
.
classRef
- an IClassRef
of a class
IClassInfo
of the class
GarbageCollectedException
SpiException
IClassRef[] getClasses(java.lang.String className, Policy policy) throws SpiException
Feature.CLASS_IDS
.
Note that null may be returned, if the policy
allows it.
className
- a class namepolicy
- the policy to use
SpiException
IClassRef[] getClasses(ITypeSpecifier specifier, Policy policy) throws SpiException
Feature.CLASS_IDS
.
Note that null may be returned, if the policy
allows it.
specifier
- a type specifierpolicy
- the policy to use
specifier
, or
null according to policy
SpiException
ITruncatable<IObjectInfo> getInstances(IClassRef classRef, int maxInstances) throws GarbageCollectedException, SpiException
Feature.INSTANCES_OF_TYPE
.
classRef
- a type referencemaxInstances
- the maximum number of instances to return, use
UNLIMITED_INSTANCES
to return all instances
ITruncatable
with IObjectInfo
s of all instances
of classRef
GarbageCollectedException
- if the class designated by classRef
has been
garbage collected.
SpiException
ITypeHeapInfo<IClassInfo> getLastTypeHeapInfo(IClassInfo classInfo, Policy policy)
classInfo
- policy
- a time stamp in milliseconds
ITypeHeapInfo<?> getLastTypeHeapInfo(java.lang.String refType, Policy policy)
refType
- policy
- a time stamp in milliseconds
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |