com.jrockit.memleak.mlp
Class AbstractMemLeak

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

public abstract class AbstractMemLeak
extends MemLeakAdapter

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
protected  class AbstractMemLeak.AsyncCallbackThread
           
protected  class AbstractMemLeak.DelayedResult<V>
           
protected  class AbstractMemLeak.DelayedTruncatable<T>
           
protected  class AbstractMemLeak.ReqProcessor<T>
           
protected  class AbstractMemLeak.VoidResult
          IResult implementation that always returns null.
 
Field Summary
protected  AbstractMemLeak.AsyncCallbackThread callbackThread
           
protected  com.jrockit.memleak.mlp.CommunicationChannel channel
           
protected  ITypeResolver<IClassInfo> classInfoResolver
          The IClassInfo resolver
protected  java.util.EnumSet<RequestType> enabledRequests
           
protected  IMemleakValueFactory factory
          The value factory
protected  java.util.Set<Feature> features
           
protected  double histogramCutoff
           
protected  IInfoCacheControl infoCache
          The value cache
static IClassInfo INVALID_CLASS_INFO
          Sentinel IClassInfo used as a return value from utility methods to mark the end of a sequence of IClassInfo:s (of unknown length).
static IObjectInfo INVALID_OBJECT_INFO
          Sentinel IObjectInfo used as a return value from utility methods to mark the end of a sequence of IObjectInfo:s (of unknown length).
static java.lang.String META_MLP_REQUEST_REVISIONS
          Key for getMetaData(Object) to obtain request revisions as an int array.
static java.lang.String META_SUPPORTED_MLP_REQUESTS
          Key for getMetaData(Object) to obtain supported requests as a EnumSet<RequestType>.
protected  NotificationService<java.lang.Object> notificationService
           
protected  long 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
protected AbstractMemLeak(com.jrockit.memleak.mlp.CommunicationChannel channel, int port)
          Create a new instance for the established connection.
 
Method Summary
protected  void checkSpecValidity(IObjectSpecifier objectSpec)
          Check that the given IObjectSpecifier is non-null and valid, that is, doesn't have the IDs OBJECT_ID_INVALID or OBJECT_ID_NULL.
protected  void checkSupported(RequestType requestType)
          Is the given request type supported by the server?
protected abstract  com.jrockit.memleak.mlp.ServerRequest createEnableAllocTracesForClassReq(ITypeSpecifier type, int bufferSize, int interval)
           
protected abstract  com.jrockit.memleak.mlp.ServerRequest createHeapHistogramReq()
           
static IMemLeak createMemLeak(java.net.Socket socket, int port)
          Convenience constructor for testing.
static IMemLeak createMemLeak(java.lang.String host, int port)
          Create a new IMemLeak instance which will be connected to the server.
protected  java.util.EnumSet<RequestType> createSafeSupportedReqs()
          Default supported MLP requests, as for pre-R28.x JRockits.
protected abstract  com.jrockit.memleak.mlp.ServerRequest createTypesPointingToReq(ITypeSpecifier type)
           
 void deleteObjectId(int objectId)
          Delete the given object ID.
 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.
 int getAllocTraceFrequency()
          Get the current allocation trace report interval.
 int getArrayLength(IObjectSpecifier objectSpec)
          Get the length of an array.
 java.util.Set<Feature> getFeatures()
           
 IHeapHistogram getHeapHistogram()
          Get a histogram of the heap.
 double getHistogramCutoff()
          Get the cutoff point for types in the heap histograms.
 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.
<S> S
getService(java.lang.Class<S> interfaceClass)
          Return the service interface of type interfaceClass, if supported.
protected  java.util.EnumSet<RequestType> getSupportedRequests()
          Experimental, for testing only, to determine supported request types.
 IPointToTypeInfo[] getTypesPointingTo(ITypeSpecifier type, Policy policy)
          Find which types contain references to another type.
protected  void initFeatures(java.util.EnumSet<Feature> features, java.util.EnumSet<RequestType> requests)
          Initialize the feature set based on the supported requests.
 boolean isAllocTracesEnabled()
          Check if allocation traces are already enabled.
 boolean isConnected()
          Returns true if we're connected to a (JRockit) server, false otherwise.
protected  boolean isJlcClass(IClassInfo clsInfo)
           
 boolean isTrendAnalysisEnabled()
          Check whether trend analysis is enabled on the server.
protected abstract  ITrace[] parseAllocTraces(java.io.DataInputStream dis)
           
protected abstract  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 abstract  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 abstract  IFieldValue[] parseFieldValues(java.io.DataInputStream dis, boolean onlyStatics)
           
protected  IHeapHistogram parseHeapUsage(java.io.DataInputStream dis, double histogramCutoff)
           
protected abstract  IMethodInfo parseMethodInfo(java.io.DataInputStream dis)
           
protected abstract  IObjectInfo parseObject(java.io.DataInputStream dis)
           
protected abstract  IObjectInfo parseObject(java.io.DataInputStream dis, IClassInfo classInfo)
           
protected abstract  IObjectSpecifier parseObjectSpec(java.io.DataInputStream dis)
           
protected  IPointToTypeInfo parseTypesPointingTo(java.io.DataInputStream dis)
           
 void pollAllocationTraces()
          If allocation traces is enabled, poll the buffer on the server for any traces not yet sent to the client.
protected  java.lang.Object readPrimitive(java.io.DataInputStream dis, char type)
          Read a primitive value of the type given by type and return it in a wrapper.
protected  void reportIgnoredBytes(int numBytes)
          Report that numBytes bytes was ignored when parsing a reply, for protocol debugging purposes.
protected  void reportUnusedBytes(java.io.DataInputStream dis)
          Report the remaining number of bytes in dis as unused, for protocol debugging purposes.
 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.
protected  boolean supportsRequest(RequestType requestType)
          Is the given request type supported by the server?
 
Methods inherited from class com.jrockit.memleak.util.MemLeakAdapter
deleteAllObjectIds, deleteObjectId, enableAllocTracesForClass, getArrayData, getClasses, getClasses, getClassInfo, getFieldValues, getInstanceRelationships, getInstanceRelationships, getInstances, getInstancesPointingTo, getKeepAliveSizeOf, getLargestArrays, getLargestArrays, getObjectInfo, getPathPointingTo, getStaticFields, getTypesPointingTo, hasFeatures, pollDiscardedObjects
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

META_SUPPORTED_MLP_REQUESTS

public static final java.lang.String META_SUPPORTED_MLP_REQUESTS
Key for getMetaData(Object) to obtain supported requests as a EnumSet<RequestType>.

See Also:
Constant Field Values

META_MLP_REQUEST_REVISIONS

public static final java.lang.String META_MLP_REQUEST_REVISIONS
Key for getMetaData(Object) to obtain request revisions as an int array.

See Also:
Constant Field Values

INVALID_OBJECT_INFO

public static final IObjectInfo INVALID_OBJECT_INFO
Sentinel IObjectInfo used as a return value from utility methods to mark the end of a sequence of IObjectInfo:s (of unknown length). Not to be exposed to IMemLeak users.


INVALID_CLASS_INFO

public static final IClassInfo INVALID_CLASS_INFO
Sentinel IClassInfo used as a return value from utility methods to mark the end of a sequence of IClassInfo:s (of unknown length). Not to be exposed to IMemLeak users.


factory

protected IMemleakValueFactory factory
The value factory


infoCache

protected IInfoCacheControl infoCache
The value cache


classInfoResolver

protected ITypeResolver<IClassInfo> classInfoResolver
The IClassInfo resolver


callbackThread

protected AbstractMemLeak.AsyncCallbackThread callbackThread

channel

protected final com.jrockit.memleak.mlp.CommunicationChannel channel

notificationService

protected final NotificationService<java.lang.Object> notificationService

histogramCutoff

protected double histogramCutoff

enabledRequests

protected java.util.EnumSet<RequestType> enabledRequests

numIgnoredBytes

protected long numIgnoredBytes

features

protected java.util.Set<Feature> features
Constructor Detail

AbstractMemLeak

protected AbstractMemLeak(com.jrockit.memleak.mlp.CommunicationChannel channel,
                          int port)
Create a new instance for the established connection. Note that after calling this constructor, subclasses must initialize the factory and infoCache fields.

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

createMemLeak

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

Parameters:
host - name of the host
port - port on the host
Returns:
a connected IMemLeak instance
Throws:
java.io.IOException - if there is a communication related problem, more specifically:

java.net.UnknownHostException if the host could not be found. java.net.ConnectException if no server could be found at the specified port. IllegalArgumentException if the port is out of range.

SpiException

createMemLeak

public static IMemLeak createMemLeak(java.net.Socket socket,
                                     int port)
                              throws java.io.IOException,
                                     SpiException
Convenience constructor for testing.

Parameters:
socket -
port -
Returns:
a connected IMemLeak instance
Throws:
java.io.IOException
SpiException
See Also:
createMemLeak(String, int)

createSafeSupportedReqs

protected java.util.EnumSet<RequestType> createSafeSupportedReqs()
Default supported MLP requests, as for pre-R28.x JRockits.

Returns:
an EnumSet<RequestType>

getSupportedRequests

protected java.util.EnumSet<RequestType> getSupportedRequests()
                                                       throws SpiException
Experimental, for testing only, to determine supported request types.

Returns:
supported requests
Throws:
SpiException

supportsRequest

protected boolean supportsRequest(RequestType requestType)
                           throws SpiException
Is the given request type supported by the server?

Parameters:
requestType -
Returns:
true if the given request type is supported by the server, false otherwise
Throws:
SpiException

checkSupported

protected void checkSupported(RequestType requestType)
                       throws SpiException
Is the given request type supported by the server?

Parameters:
requestType -
Throws:
SpiException - if the given request type is unsupported by the server

reportIgnoredBytes

protected void reportIgnoredBytes(int numBytes)
Report that numBytes bytes was ignored when parsing a reply, for protocol debugging purposes.

Parameters:
numBytes -

reportUnusedBytes

protected void reportUnusedBytes(java.io.DataInputStream dis)
Report the remaining number of bytes in dis as unused, for protocol debugging purposes. Ignores any IOExceptions.

Parameters:
dis -

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
Overrides:
getMetaData in class MemLeakAdapter
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
Overrides:
getFeatures in class MemLeakAdapter
Returns:
a Set containing the Features this IMemLeak instance supports.

initFeatures

protected void initFeatures(java.util.EnumSet<Feature> features,
                            java.util.EnumSet<RequestType> requests)
Initialize the feature set based on the supported requests.

Parameters:
features -
requests -

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
Overrides:
getService in class MemLeakAdapter
Returns:
an instance of S, or null if the service isn't supported.

isJlcClass

protected boolean isJlcClass(IClassInfo clsInfo)
Parameters:
clsInfo -
Returns:
true iff clsInfo is the class info for java.lang.Class.

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
Overrides:
setTrendAnalysisCallback in class MemLeakAdapter
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
Overrides:
setTrendAnalysisEnabled in class MemLeakAdapter
Throws:
java.lang.IllegalStateException - if no callback has been registered
SpiException

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
Overrides:
isTrendAnalysisEnabled in class MemLeakAdapter
Returns:
whether trend anlysis is enabled on the server
Throws:
SpiException

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
Overrides:
getHeapHistogram in class MemLeakAdapter
Returns:
a histogram of the heap
Throws:
SpiException

createHeapHistogramReq

protected abstract com.jrockit.memleak.mlp.ServerRequest createHeapHistogramReq()
Returns:
a ServerRequest

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
Overrides:
setHistogramCutoff in class MemLeakAdapter
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()

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
Overrides:
getHistogramCutoff in class MemLeakAdapter
Returns:
the current cutoff point
See Also:
IMemLeak.setHistogramCutoff(double)

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

createTypesPointingToReq

protected abstract com.jrockit.memleak.mlp.ServerRequest createTypesPointingToReq(ITypeSpecifier type)
Parameters:
type -
Returns:
a ServerRequest (FIXME:or null?)

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
Overrides:
getArrayLength in class MemLeakAdapter
Parameters:
objectSpec - the array
Returns:
the length of the array
Throws:
GarbageCollectedException
SpiException

checkSpecValidity

protected void checkSpecValidity(IObjectSpecifier objectSpec)
                          throws NoSuchIdException,
                                 GarbageCollectedException
Check that the given IObjectSpecifier is non-null and valid, that is, doesn't have the IDs OBJECT_ID_INVALID or OBJECT_ID_NULL.

Parameters:
objectSpec -
Throws:
NoSuchIdException - if objectSpec isn't valid.
GarbageCollectedException - if objectSpec is discarded
java.lang.NullPointerException - if objectSpec is null.

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

createEnableAllocTracesForClassReq

protected abstract com.jrockit.memleak.mlp.ServerRequest createEnableAllocTracesForClassReq(ITypeSpecifier type,
                                                                                            int bufferSize,
                                                                                            int interval)
Parameters:
type -
bufferSize -
interval -
Returns:
a ServerRequest

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
Overrides:
pollAllocationTraces in class MemLeakAdapter
Throws:
java.lang.IllegalStateException
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
Overrides:
isAllocTracesEnabled in class MemLeakAdapter
Returns:
whether allocation traces are already enabled
Throws:
SpiException

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
Overrides:
disableAllocTraces in class MemLeakAdapter
Throws:
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
Overrides:
setAllocTraceFrequency in class MemLeakAdapter
Parameters:
reportInterval - the number of allocations that has to occur before an allocation trace will be reported
Throws:
SpiException

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
Overrides:
getAllocTraceFrequency in class MemLeakAdapter
Returns:
the number of allocations that has to occur before an allocation trace will be reported
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
Overrides:
doFullGC in class MemLeakAdapter
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
Overrides:
deleteObjectId in class MemLeakAdapter
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
Overrides:
deleteObjectIds in class MemLeakAdapter
Parameters:
objectIds - an array of object IDs
Returns:
An IResult whose get() method will return null

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
Overrides:
destroy in class MemLeakAdapter
Throws:
java.io.IOException

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
Overrides:
setDisconnectCallback in class MemLeakAdapter
Parameters:
disconnectCallback - the callback that handles the exception that was thrown due to the communication error.

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
Overrides:
isConnected in class MemLeakAdapter
Returns:
true or false

parseTypesPointingTo

protected IPointToTypeInfo parseTypesPointingTo(java.io.DataInputStream dis)
                                         throws java.io.IOException,
                                                GarbageCollectedException,
                                                SpiException
Parameters:
dis -
Returns:
an IPointToTypeInfo
Throws:
java.io.IOException
GarbageCollectedException
SpiException

getLastTypeHeapInfo

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

parseHeapUsage

protected IHeapHistogram parseHeapUsage(java.io.DataInputStream dis,
                                        double histogramCutoff)
                                 throws java.io.IOException,
                                        SpiException
Parameters:
dis -
histogramCutoff -
Returns:
an IHeapHistogram
Throws:
java.io.IOException
SpiException

parseFieldValues

protected abstract IFieldValue[] parseFieldValues(java.io.DataInputStream dis,
                                                  boolean onlyStatics)
                                           throws java.io.IOException,
                                                  GarbageCollectedException,
                                                  SpiException
Parameters:
dis -
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 abstract IMethodInfo parseMethodInfo(java.io.DataInputStream dis)
                                        throws java.io.IOException,
                                               GarbageCollectedException,
                                               SpiException
Parameters:
dis -
Returns:
a IMethodInfo
Throws:
java.io.IOException
SpiException
GarbageCollectedException

readPrimitive

protected java.lang.Object readPrimitive(java.io.DataInputStream dis,
                                         char type)
                                  throws java.io.IOException
Read a primitive value of the type given by type and return it in a wrapper.

Parameters:
dis -
type -
Returns:
a primitive wrapper object
Throws:
java.io.IOException
java.lang.IllegalArgumentException - if type is not a char in "ZBCSIJFD".

parseAllocTraces

protected abstract ITrace[] parseAllocTraces(java.io.DataInputStream dis)
                                      throws java.io.IOException,
                                             GarbageCollectedException,
                                             SpiException
Parameters:
dis -
Returns:
an ITrace array
Throws:
java.io.IOException
GarbageCollectedException
SpiException

parseObject

protected abstract IObjectInfo parseObject(java.io.DataInputStream dis)
                                    throws java.io.IOException,
                                           GarbageCollectedException,
                                           SpiException
Parameters:
dis -
Returns:
an IObjectInfo
Throws:
java.io.IOException
GarbageCollectedException
SpiException

parseObject

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

parseObjectSpec

protected abstract IObjectSpecifier parseObjectSpec(java.io.DataInputStream dis)
                                             throws java.io.IOException,
                                                    SpiException
Parameters:
dis -
Returns:
an IObjectSpecifier or null if the object reference is null.
Throws:
java.io.IOException - iff an I/O operation on dis failed.
GarbageCollectedException - if a sub-request indicated that this object must have been Garbage Collected.
SpiException - if a required sub-request (not on dis) failed.

parseClass

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

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.
GarbageCollectedException - if a sub-request indicated that this class must have been Garbage Collected.
SpiException - if a required sub-request (not on dis) failed.

parseClassRef

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

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.
GarbageCollectedException - if a sub-request indicated that this class must have been Garbage Collected.
SpiException - if a required sub-request (not on dis) failed.


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