com.jrockit.memleak.mlp
Class MemLeakR26

java.lang.Object
  extended by com.jrockit.memleak.util.MemLeakAdapter
      extended by com.jrockit.memleak.mlp.AbstractMemLeak
          extended by com.jrockit.memleak.mlp.MemLeakR26
All Implemented Interfaces:
IMemLeak

public class MemLeakR26
extends AbstractMemLeak

Gives access to the memory leak detection system in JRockit.

Since:
Creation date: 2004-sep-01
Author:
Staffan Larsen, Helena ┼berg Ístlund

Nested Class Summary
 class MemLeakR26.LargestArrayR26
           
 
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
MemLeakR26(com.jrockit.memleak.mlp.CommunicationChannel channel, int port)
          Create a new instance for the established connection.
MemLeakR26(java.lang.String host, int port)
          Create a new MemLeak instance which will be connected to the server.
 
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 createInstanceRelationshipsReq(ITypeSpecifier fromType, ITypeSpecifier toType, int maxRelations, long stopAt, int maxMillis)
           
protected  com.jrockit.memleak.mlp.ServerRequest createTypesPointingToReq(ITypeSpecifier type)
           
 IResult<IValue[]> getArrayData(IObjectSpecifier objectSpec, int from, int len)
          Get the data from an array.
 IClassInfo getClassInfo(IClassRef classRef)
          Requires Feature.CLASS_NAME_OF_OBJECT.
 IResult<IFieldValue[]> getFieldValues(IObjectSpecifier objectSpec)
          Get values and names for all fields in the object identified by objectSpec.
 ITruncatable<IRelationshipInfo> getInstanceRelationships(ITypeSpecifier fromType, ITypeSpecifier toType, int maxRelations, long stopAt, int maxMillis)
          Get all instances of fromType that points to instances of toType.
 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.
 IResult<IObjectInfo> getObjectInfo(IObjectSpecifier objectSpec)
          Requires Feature.CLASS_NAME_OF_OBJECT.
 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  IFieldValue[] parseFieldValues(java.io.DataInputStream dis, boolean onlyStatics)
           
protected  ITruncatable<IRelationshipInfo> parseInstanceRelationsships(java.io.DataInputStream dis, ITypeSpecifier fromType)
           
protected  IMethodInfo parseMethodInfo(java.io.DataInputStream dis)
           
protected  IObjectInfo parseObject(java.io.DataInputStream dis)
           
protected  IObjectInfo parseObject(java.io.DataInputStream dis, IClassInfo classInfo)
           
protected  IObjectInfo parseObjectAndClass(java.io.DataInputStream dis)
          Used where there traditionally has been an object ID followed by a class name.
protected  IObjectSpecifier parseObjectSpec(java.io.DataInputStream dis)
           
 
Methods inherited from class com.jrockit.memleak.mlp.AbstractMemLeak
checkSpecValidity, checkSupported, createMemLeak, createMemLeak, createSafeSupportedReqs, deleteObjectId, deleteObjectIds, destroy, disableAllocTraces, doFullGC, enableAllocTracesForClass, getAllocTraceFrequency, getArrayLength, getFeatures, getHeapHistogram, getHistogramCutoff, getLastTypeHeapInfo, getLastTypeHeapInfo, getMetaData, getService, getSupportedRequests, getTypesPointingTo, isAllocTracesEnabled, isConnected, isJlcClass, isTrendAnalysisEnabled, parseHeapUsage, parseTypesPointingTo, pollAllocationTraces, readPrimitive, reportIgnoredBytes, reportUnusedBytes, setAllocTraceFrequency, setDisconnectCallback, setHistogramCutoff, setTrendAnalysisCallback, setTrendAnalysisEnabled, supportsRequest
 
Methods inherited from class com.jrockit.memleak.util.MemLeakAdapter
deleteAllObjectIds, deleteObjectId, enableAllocTracesForClass, getClasses, getClasses, getInstanceRelationships, getInstances, getLargestArrays, getPathPointingTo, getTypesPointingTo, hasFeatures, pollDiscardedObjects
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemLeakR26

public MemLeakR26(java.lang.String host,
                  int port)
           throws java.io.IOException
Create a new MemLeak instance which will be connected to the server.

Parameters:
host - name of the host
port - port on the host
Throws:
java.io.IOException - if there is a communication related problem, more specifically:
  • UnknownHostException if the host could not be found.
  • ConnectException if no server could be found at the specified port.
  • IllegalArgumentException if the port is out of range.

MemLeakR26

public MemLeakR26(com.jrockit.memleak.mlp.CommunicationChannel channel,
                  int port)
Create a new instance for the established connection.

Parameters:
channel - established communication channel
port - port on the host
Method Detail

initFeatures

protected void initFeatures(java.util.EnumSet<Feature> features,
                            java.util.EnumSet<RequestType> requests)
Description copied from class: AbstractMemLeak
Initialize the feature set based on the supported requests.

Overrides:
initFeatures in class AbstractMemLeak

createHeapHistogramReq

protected com.jrockit.memleak.mlp.ServerRequest createHeapHistogramReq()
Specified by:
createHeapHistogramReq in class AbstractMemLeak
Returns:
a ServerRequest

createTypesPointingToReq

protected com.jrockit.memleak.mlp.ServerRequest createTypesPointingToReq(ITypeSpecifier type)
Specified by:
createTypesPointingToReq in class AbstractMemLeak
Returns:
a ServerRequest (FIXME:or null?)

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
Overrides:
getLargestArrays in class MemLeakAdapter
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

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
Overrides:
getInstancesPointingTo in class MemLeakAdapter
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

createInstanceRelationshipsReq

protected com.jrockit.memleak.mlp.ServerRequest createInstanceRelationshipsReq(ITypeSpecifier fromType,
                                                                               ITypeSpecifier toType,
                                                                               int maxRelations,
                                                                               long stopAt,
                                                                               int maxMillis)
Parameters:
fromType -
toType -
maxRelations -
stopAt -
maxMillis -
Returns:
a ServerRequest

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
Overrides:
getFieldValues in class MemLeakAdapter
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
Overrides:
getStaticFields in class MemLeakAdapter
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.

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
Overrides:
getArrayData in class MemLeakAdapter
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.

createEnableAllocTracesForClassReq

protected com.jrockit.memleak.mlp.ServerRequest createEnableAllocTracesForClassReq(ITypeSpecifier type,
                                                                                   int bufferSize,
                                                                                   int interval)
Specified by:
createEnableAllocTracesForClassReq in class AbstractMemLeak
Returns:
a ServerRequest

parseAllocTraces

protected ITrace[] parseAllocTraces(java.io.DataInputStream dis)
                             throws java.io.IOException,
                                    GarbageCollectedException,
                                    SpiException
Specified by:
parseAllocTraces in class AbstractMemLeak
Returns:
an ITrace array
Throws:
java.io.IOException
GarbageCollectedException
SpiException

parseFieldValues

protected IFieldValue[] parseFieldValues(java.io.DataInputStream dis,
                                         boolean onlyStatics)
                                  throws java.io.IOException,
                                         GarbageCollectedException,
                                         SpiException
Specified by:
parseFieldValues in class AbstractMemLeak
onlyStatics - if only static fields should be included. (Will only return any fields for java.lang.Class objects.)
Returns:
an IFieldValue array
Throws:
java.io.IOException
GarbageCollectedException
SpiException

parseMethodInfo

protected IMethodInfo parseMethodInfo(java.io.DataInputStream dis)
                               throws java.io.IOException
Specified by:
parseMethodInfo in class AbstractMemLeak
Returns:
a IMethodInfo
Throws:
java.io.IOException

parseObject

protected IObjectInfo parseObject(java.io.DataInputStream dis)
                           throws java.io.IOException
Specified by:
parseObject in class AbstractMemLeak
Returns:
an IObjectInfo
Throws:
java.io.IOException

parseObject

protected IObjectInfo parseObject(java.io.DataInputStream dis,
                                  IClassInfo classInfo)
                           throws java.io.IOException
Specified by:
parseObject in class AbstractMemLeak
classInfo - a IClassInfo to use for the object, unless already known or in stream.
Returns:
an IObjectInfo
Throws:
java.io.IOException

parseObjectSpec

protected IObjectSpecifier parseObjectSpec(java.io.DataInputStream dis)
                                    throws java.io.IOException
Specified by:
parseObjectSpec in class AbstractMemLeak
Returns:
an IObjectSpecifier or null if the object reference is null.
Throws:
java.io.IOException - iff an I/O operation on dis failed.

getObjectInfo

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

Specified by:
getObjectInfo in interface IMemLeak
Overrides:
getObjectInfo in class MemLeakAdapter
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.

parseObjectAndClass

protected IObjectInfo parseObjectAndClass(java.io.DataInputStream dis)
                                   throws java.io.IOException,
                                          SpiException
Used where there traditionally has been an object ID followed by a class name.

Parameters:
dis -
Returns:
an IObjectInfo
Throws:
java.io.IOException
SpiException

parseClass

protected IClassInfo parseClass(java.io.DataInputStream dis)
                         throws java.io.IOException
Description copied from class: AbstractMemLeak
Read a class from a stream, obtaining data required, but not provided in the stream, from caches or by implicit sub-requests.

Specified by:
parseClass in class AbstractMemLeak
Parameters:
dis - the stream to read the class identity from
Returns:
an IClassInfo
Throws:
java.io.IOException - iff an I/O operation on dis failed.

parseClassRef

protected IClassRef parseClassRef(java.io.DataInputStream dis)
                           throws java.io.IOException,
                                  SpiException
Description copied from class: AbstractMemLeak
Read a class from a stream, obtaining data required, but not provided in the stream, from caches or by implicit sub-requests.

Specified by:
parseClassRef in class AbstractMemLeak
Parameters:
dis - the stream to read the class identity from
Returns:
an IClassInfo
Throws:
java.io.IOException - iff an I/O operation on dis failed.
SpiException - if a required sub-request (not on dis) failed.

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
Overrides:
getClassInfo in class MemLeakAdapter
Parameters:
classRef - an IClassRef of a class
Returns:
the IClassInfo of the class
Throws:
GarbageCollectedException
SpiException

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
Overrides:
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 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)

parseInstanceRelationsships

protected ITruncatable<IRelationshipInfo> parseInstanceRelationsships(java.io.DataInputStream dis,
                                                                      ITypeSpecifier fromType)
                                                               throws java.io.IOException
Parameters:
dis -
fromType -
Returns:
an ITruncatable<IRelationshipInfo>
Throws:
java.io.IOException

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
Overrides:
getKeepAliveSizeOf in class MemLeakAdapter
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.


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