|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jrockit.memleak.util.MemLeakAdapter
com.jrockit.memleak.mlp.AbstractMemLeak
com.jrockit.memleak.mlp.MemLeakR28
public class MemLeakR28
Gives access to the memory leak detection system in JRockit.
Nested Class Summary | |
---|---|
class |
MemLeakR28.GetClassesR28
|
class |
MemLeakR28.GetInstanceRelationshipsR28
|
class |
MemLeakR28.LargestArrayR28
|
Nested classes/interfaces inherited from class com.jrockit.memleak.mlp.AbstractMemLeak |
---|
AbstractMemLeak.AsyncCallbackThread, AbstractMemLeak.DelayedResult<V>, AbstractMemLeak.DelayedTruncatable<T>, AbstractMemLeak.ReqProcessor<T>, AbstractMemLeak.VoidResult |
Field Summary |
---|
Fields inherited from class com.jrockit.memleak.mlp.AbstractMemLeak |
---|
callbackThread, channel, classInfoResolver, enabledRequests, factory, features, histogramCutoff, infoCache, INVALID_CLASS_INFO, INVALID_OBJECT_INFO, META_MLP_REQUEST_REVISIONS, META_SUPPORTED_MLP_REQUESTS, notificationService, numIgnoredBytes |
Fields inherited from class com.jrockit.memleak.util.MemLeakAdapter |
---|
EMPTY_INT_ARRAY, metaData |
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 | |
---|---|
MemLeakR28(com.jrockit.memleak.mlp.CommunicationChannel channel,
int port)
Create a new instance for the established connection. |
Method Summary | |
---|---|
protected com.jrockit.memleak.mlp.ServerRequest |
createEnableAllocTracesForClassReq(ITypeSpecifier type,
int bufferSize,
int interval)
|
protected com.jrockit.memleak.mlp.ServerRequest |
createHeapHistogramReq()
|
protected com.jrockit.memleak.mlp.ServerRequest |
createTypesPointingToReq(ITypeSpecifier type)
|
void |
deleteAllObjectIds()
Delete all object IDs. |
void |
deleteObjectId(int objectId)
Delete the given object ID. |
IResult<java.lang.Void> |
deleteObjectIds(int... objectIds)
Delete the object IDs in objectIds . |
protected IClassInfo |
findJavaLangClass()
|
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 . |
IClassInfo |
getClassInfo(IClassRef classRef)
Requires Feature.CLASS_NAME_OF_OBJECT . |
protected IClassInfo |
getClassInfo(int classID)
Find the IClassInfo cached locally, or if not found, retrieve it
from the server. |
int[] |
getDiscardedIDs(IObjectSpecifier... objectSpecs)
|
IResult<IFieldValue[]> |
getFieldValues(IObjectSpecifier objectSpec)
Get values and names for all fields in the object identified by objectSpec. |
protected java.io.DataInputStream |
getInputStreamHandlingDiscarded(com.jrockit.memleak.mlp.ServerResponse response,
IObjectSpecifier objectSpec)
Create input stream from response, but in case of a GarbageCollectedException , also mark the IObjectInfo
corresponding to objectSpec as discarded, if possible. |
protected java.io.DataInputStream |
getInspectStreamHandlingDiscarded(com.jrockit.memleak.mlp.ServerResponse response,
IObjectSpecifier objectSpec)
Create input stream from response, but in case of a GarbageCollectedException , also mark the IObjectInfo
corresponding to objectSpec as discarded, if possible. |
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<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. |
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 . |
protected IObjectInfo |
getObjectInfoBlocking(int objID)
Find the IObjectInfo cached locally, or if not found, retrieve it
from the server. |
ITruncatable<IInstanceReferrers> |
getPathPointingTo(IObjectSpecifier objectSpec,
int maxDepth,
int maxMillis)
Find a path from a GC root to the object denoted by objectSpec . |
protected int[] |
getRequestRevisions()
Experimental, for testing only, to determine request revisions. |
IResult<IFieldValue[]> |
getStaticFields(IClassRef classRef)
Get values and names for all static fields in the class identified by classRef. |
protected void |
initFeatures(java.util.EnumSet<Feature> features,
java.util.EnumSet<RequestType> requests)
Initialize the feature set based on the supported requests. |
protected ITrace[] |
parseAllocTraces(java.io.DataInputStream dis)
|
protected IClassInfo |
parseClass(java.io.DataInputStream dis)
Read a class from a stream, obtaining data required, but not provided in the stream, from caches or by implicit sub-requests. |
protected IClassRef |
parseClassRef(java.io.DataInputStream dis)
Read a class from a stream, obtaining data required, but not provided in the stream, from caches or by implicit sub-requests. |
protected IClassInfo |
parseClassWithMetaData(java.io.DataInputStream dis)
Parse a class ID followed by meta data. |
protected IFieldValue[] |
parseFieldValues(java.io.DataInputStream dis,
boolean onlyStatics)
|
protected IInstanceReferrers |
parseInstancePointingTo(java.io.DataInputStream dis)
|
protected IMethodInfo |
parseMethodInfo(java.io.DataInputStream dis)
|
protected IObjectInfo |
parseObject(java.io.DataInputStream dis)
|
protected IObjectInfo |
parseObject(java.io.DataInputStream dis,
IClassInfo classInfo)
|
protected IObjectSpecifier |
parseObjectSpec(java.io.DataInputStream dis)
|
boolean |
pollDiscardedObjects()
If supported, poll the server for objects (and classes) that have been garbage collected. |
boolean |
setVerboseMLP(MlpVerbosity objects,
MlpVerbosity classes,
MlpVerbosity classLoaders)
Attempt to set protocol verbosity. |
protected static boolean |
supportsMlpVersion(int major,
int minor)
|
protected void |
tryMarkDiscarded(IObjectSpecifier objectSpec)
Mark the IObjectInfo corresponding to objectSpec as
discarded, if possible. |
Methods inherited from class com.jrockit.memleak.util.MemLeakAdapter |
---|
deleteObjectId, enableAllocTracesForClass, getClasses, getInstanceRelationships, getLargestArrays, getTypesPointingTo, hasFeatures |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MemLeakR28(com.jrockit.memleak.mlp.CommunicationChannel channel, int port) throws SpiException
channel
- established communication channelport
- port on the host
SpiException
Method Detail |
---|
protected static boolean supportsMlpVersion(int major, int minor)
major
- minor
-
protected IClassInfo findJavaLangClass()
IClassInfo
for java.lang.Class. Used to construct
IObjectInfo
s for IClassInfo
s.public boolean setVerboseMLP(MlpVerbosity objects, MlpVerbosity classes, MlpVerbosity classLoaders) throws SpiException
objects
- classes
- classLoaders
-
SpiException
protected void initFeatures(java.util.EnumSet<Feature> features, java.util.EnumSet<RequestType> requests)
AbstractMemLeak
initFeatures
in class AbstractMemLeak
protected int[] getRequestRevisions() throws SpiException
Enum.ordinal()
SpiException
public java.lang.Object getMetaData(java.lang.Object key) throws SpiException
IMemLeak
getMetaData
in interface IMemLeak
getMetaData
in class AbstractMemLeak
key
- The kind of meta data to return
SpiException
protected com.jrockit.memleak.mlp.ServerRequest createHeapHistogramReq()
createHeapHistogramReq
in class AbstractMemLeak
ServerRequest
protected com.jrockit.memleak.mlp.ServerRequest createTypesPointingToReq(ITypeSpecifier type)
createTypesPointingToReq
in class AbstractMemLeak
ServerRequest
(FIXME:or null?)public ITruncatable<IArraySizeInfo> getLargestArrays(ITypeSpecifier type)
IMemLeak
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.
getLargestArrays
in interface IMemLeak
getLargestArrays
in class MemLeakAdapter
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 loadedpublic IInstanceReferrers getInstancesPointingTo(IObjectSpecifier objectSpec, Policy policy) throws GarbageCollectedException, SpiException
IMemLeak
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.
getInstancesPointingTo
in interface IMemLeak
getInstancesPointingTo
in class MemLeakAdapter
objectSpec
- an object specifierpolicy
- the policy to use
GarbageCollectedException
SpiException
protected java.io.DataInputStream getInputStreamHandlingDiscarded(com.jrockit.memleak.mlp.ServerResponse response, IObjectSpecifier objectSpec) throws GarbageCollectedException, SpiException
GarbageCollectedException
, also mark the IObjectInfo
corresponding to objectSpec
as discarded, if possible.
response
- objectSpec
-
GarbageCollectedException
SpiException
protected java.io.DataInputStream getInspectStreamHandlingDiscarded(com.jrockit.memleak.mlp.ServerResponse response, IObjectSpecifier objectSpec) throws GarbageCollectedException, SpiException
GarbageCollectedException
, also mark the IObjectInfo
corresponding to objectSpec
as discarded, if possible.
response
- objectSpec
-
GarbageCollectedException
SpiException
protected void tryMarkDiscarded(IObjectSpecifier objectSpec)
IObjectInfo
corresponding to objectSpec
as
discarded, if possible.
objectSpec
- protected IInstanceReferrers parseInstancePointingTo(java.io.DataInputStream dis) throws java.io.IOException, GarbageCollectedException, SpiException
dis
-
IInstanceReferrers
java.io.IOException
GarbageCollectedException
SpiException
public ITruncatable<IInstanceReferrers> getPathPointingTo(IObjectSpecifier objectSpec, int maxDepth, int maxMillis) throws GarbageCollectedException, OperationException, SpiException
IMemLeak
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
.
getPathPointingTo
in interface IMemLeak
getPathPointingTo
in class MemLeakAdapter
objectSpec
- 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 ITruncatable<IRelationshipInfo> getInstanceRelationships(ITypeSpecifier fromType, ITypeSpecifier toType, int maxRelations, long stopAt, int maxMillis) throws OperationException, SpiException
IMemLeak
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.
getInstanceRelationships
in interface IMemLeak
getInstanceRelationships
in class MemLeakAdapter
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 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 IRelationshipInfo
s on all
instances of fromType that points to instances of
toType.
OperationException
SpiException
IMemLeak.getKeepAliveSizeOf(IObjectSpecifier, long)
public IResult<LimitedNumber> getKeepAliveSizeOf(IObjectSpecifier objectSpec, long stopAt)
IMemLeak
stopAt
>= 0 than counting will
stop if the total size is larger than stopAt
.
getKeepAliveSizeOf
in interface IMemLeak
getKeepAliveSizeOf
in class MemLeakAdapter
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
.public IResult<IFieldValue[]> getFieldValues(IObjectSpecifier objectSpec)
IMemLeak
getFieldValues
in interface IMemLeak
getFieldValues
in class MemLeakAdapter
objectSpec
- an object specifier
IResult
whose get()
method
either will return an array of IFieldValue
s representing
the fields, or throw an exception.public IResult<IFieldValue[]> getStaticFields(IClassRef classRef)
IMemLeak
getStaticFields
in interface IMemLeak
getStaticFields
in class MemLeakAdapter
classRef
- a class reference
IResult
whose get()
method
either will return an array of IFieldValue
s representing
the static fields, or throw an exception.public IResult<IValue[]> getArrayData(IObjectSpecifier objectSpec, int from, int len)
IMemLeak
getArrayData
in interface IMemLeak
getArrayData
in class MemLeakAdapter
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.protected com.jrockit.memleak.mlp.ServerRequest createEnableAllocTracesForClassReq(ITypeSpecifier type, int bufferSize, int interval)
createEnableAllocTracesForClassReq
in class AbstractMemLeak
ServerRequest
public void deleteObjectId(int objectId) throws SpiException
IMemLeak
Requires Feature.DELETE_OBJECT_ID
.
deleteObjectId
in interface IMemLeak
deleteObjectId
in class AbstractMemLeak
objectId
- an object ID
SpiException
public IResult<java.lang.Void> deleteObjectIds(int... objectIds)
IMemLeak
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
.
deleteObjectIds
in interface IMemLeak
deleteObjectIds
in class AbstractMemLeak
objectIds
- an array of object IDs
IResult
whose get()
method
will return nullpublic void deleteAllObjectIds() throws SpiException
IMemLeak
Requires Feature.DELETE_ALL_OBJECT_IDS
.
deleteAllObjectIds
in interface IMemLeak
deleteAllObjectIds
in class MemLeakAdapter
SpiException
public boolean pollDiscardedObjects()
IMemLeak
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.
pollDiscardedObjects
in interface IMemLeak
pollDiscardedObjects
in class MemLeakAdapter
public int getArrayLength(IObjectSpecifier objectSpec) throws GarbageCollectedException, SpiException
IMemLeak
getArrayLength
in interface IMemLeak
getArrayLength
in class AbstractMemLeak
objectSpec
- the array
GarbageCollectedException
SpiException
public IResult<IObjectInfo> getObjectInfo(IObjectSpecifier objectSpec)
IMemLeak
Feature.CLASS_NAME_OF_OBJECT
.
getObjectInfo
in interface IMemLeak
getObjectInfo
in class MemLeakAdapter
objectSpec
- an IObjectSpecifier
of an instance
IResult
whose get()
method
either will return an IObjectInfo
representing the
instance, or throw an exception.protected IObjectInfo getObjectInfoBlocking(int objID) throws GarbageCollectedException, SpiException
IObjectInfo
cached locally, or if not found, retrieve it
from the server.
objID
-
IObjectInfo
GarbageCollectedException
SpiException
public IClassInfo getClassInfo(IClassRef classRef) throws GarbageCollectedException, SpiException
IMemLeak
Feature.CLASS_NAME_OF_OBJECT
.
getClassInfo
in interface IMemLeak
getClassInfo
in class MemLeakAdapter
classRef
- an IClassRef
of a class
IClassInfo
of the class
GarbageCollectedException
SpiException
protected IClassInfo getClassInfo(int classID) throws GarbageCollectedException, SpiException
IClassInfo
cached locally, or if not found, retrieve it
from the server.
classID
-
IClassInfo
GarbageCollectedException
SpiException
public IClassRef[] getClasses(ITypeSpecifier type, Policy policy) throws SpiException
IMemLeak
Feature.CLASS_IDS
.
Note that null may be returned, if the policy
allows it.
getClasses
in interface IMemLeak
getClasses
in class MemLeakAdapter
type
- 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
IMemLeak
Feature.INSTANCES_OF_TYPE
.
getInstances
in interface IMemLeak
getInstances
in class MemLeakAdapter
classRef
- a type referencemaxInstances
- the maximum number of instances to return, use
IMemLeak.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
protected ITrace[] parseAllocTraces(java.io.DataInputStream dis) throws java.io.IOException, GarbageCollectedException, SpiException
parseAllocTraces
in class AbstractMemLeak
ITrace
array
java.io.IOException
GarbageCollectedException
SpiException
protected IFieldValue[] parseFieldValues(java.io.DataInputStream dis, boolean onlyStatics) throws java.io.IOException, GarbageCollectedException, SpiException
parseFieldValues
in class AbstractMemLeak
onlyStatics
- if only static fields should be included. (Will only return
any fields for java.lang.Class objects.)
IFieldValue
array
java.io.IOException
GarbageCollectedException
SpiException
protected IMethodInfo parseMethodInfo(java.io.DataInputStream dis) throws java.io.IOException, GarbageCollectedException, SpiException
parseMethodInfo
in class AbstractMemLeak
IMethodInfo
java.io.IOException
GarbageCollectedException
SpiException
protected IObjectInfo parseObject(java.io.DataInputStream dis) throws java.io.IOException, GarbageCollectedException, SpiException
parseObject
in class AbstractMemLeak
IObjectInfo
java.io.IOException
GarbageCollectedException
SpiException
protected IObjectInfo parseObject(java.io.DataInputStream dis, IClassInfo classInfo) throws java.io.IOException, SpiException
parseObject
in class AbstractMemLeak
classInfo
- a IClassInfo
to use for the object, unless already
known or in stream.
IObjectInfo
java.io.IOException
SpiException
protected IObjectSpecifier parseObjectSpec(java.io.DataInputStream dis) throws java.io.IOException, SpiException
parseObjectSpec
in class AbstractMemLeak
IObjectSpecifier
or null if the object reference is
null.
java.io.IOException
- iff an I/O operation on dis
failed.
SpiException
- if a required sub-request (not on dis
) failed.protected IClassInfo parseClassWithMetaData(java.io.DataInputStream dis) throws java.io.IOException, SpiException
ReplyTag.ID_TAG_VERBOSE_CLASS
.
dis
-
IClassInfo
java.io.IOException
SpiException
protected IClassInfo parseClass(java.io.DataInputStream dis) throws java.io.IOException, GarbageCollectedException, SpiException
AbstractMemLeak
parseClass
in class AbstractMemLeak
dis
- the stream to read the class identity from
IClassInfo
java.io.IOException
- iff an I/O operation on dis
failed.
GarbageCollectedException
- if a sub-request indicated that this class must have been
Garbage Collected.
SpiException
- if a required sub-request (not on dis
) failed.protected IClassRef parseClassRef(java.io.DataInputStream dis) throws java.io.IOException, SpiException
AbstractMemLeak
parseClassRef
in class AbstractMemLeak
dis
-
IClassRef
or null if the object no longer exist (so
the class couldn't be determined).
java.io.IOException
SpiException
public int[] getDiscardedIDs(IObjectSpecifier... objectSpecs) throws SpiException
objectSpecs
-
SpiException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |