|
||||||||||
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
public abstract class AbstractMemLeak
Gives access to the memory leak detection system in JRockit.
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. |
|
|
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 |
---|
public static final java.lang.String META_SUPPORTED_MLP_REQUESTS
getMetaData(Object)
to obtain supported requests as a
EnumSet
<RequestType
>.
public static final java.lang.String META_MLP_REQUEST_REVISIONS
getMetaData(Object)
to obtain request revisions as an
int array.
public static final IObjectInfo INVALID_OBJECT_INFO
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.
public static final IClassInfo INVALID_CLASS_INFO
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.
protected IMemleakValueFactory factory
protected IInfoCacheControl infoCache
protected ITypeResolver<IClassInfo> classInfoResolver
protected AbstractMemLeak.AsyncCallbackThread callbackThread
protected final com.jrockit.memleak.mlp.CommunicationChannel channel
protected final NotificationService<java.lang.Object> notificationService
protected double histogramCutoff
protected java.util.EnumSet<RequestType> enabledRequests
protected long numIgnoredBytes
protected java.util.Set<Feature> features
Constructor Detail |
---|
protected AbstractMemLeak(com.jrockit.memleak.mlp.CommunicationChannel channel, int port)
channel
- established communication channelport
- port on the hostMethod Detail |
---|
public static IMemLeak createMemLeak(java.lang.String host, int port) throws java.io.IOException, SpiException
IMemLeak
instance which will be connected to the
server.
host
- name of the hostport
- port on the host
IMemLeak
instance
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
public static IMemLeak createMemLeak(java.net.Socket socket, int port) throws java.io.IOException, SpiException
socket
- port
-
IMemLeak
instance
java.io.IOException
SpiException
createMemLeak(String, int)
protected java.util.EnumSet<RequestType> createSafeSupportedReqs()
EnumSet
<RequestType
>protected java.util.EnumSet<RequestType> getSupportedRequests() throws SpiException
SpiException
protected boolean supportsRequest(RequestType requestType) throws SpiException
requestType
-
SpiException
protected void checkSupported(RequestType requestType) throws SpiException
requestType
-
SpiException
- if the given request type is unsupported by the serverprotected void reportIgnoredBytes(int numBytes)
numBytes
bytes was ignored when parsing a reply,
for protocol debugging purposes.
numBytes
- protected void reportUnusedBytes(java.io.DataInputStream dis)
dis
as unused, for
protocol debugging purposes. Ignores any IOException
s.
dis
- public java.lang.Object getMetaData(java.lang.Object key) throws SpiException
IMemLeak
getMetaData
in interface IMemLeak
getMetaData
in class MemLeakAdapter
key
- The kind of meta data to return
SpiException
public java.util.Set<Feature> getFeatures()
getFeatures
in interface IMemLeak
getFeatures
in class MemLeakAdapter
Set
containing the Feature
s this
IMemLeak
instance supports.protected void initFeatures(java.util.EnumSet<Feature> features, java.util.EnumSet<RequestType> requests)
features
- requests
- public <S> S getService(java.lang.Class<S> interfaceClass)
IMemLeak
Feature
s, and future
versions of Memleak may unify these two concepts further.)
getService
in interface IMemLeak
getService
in class MemLeakAdapter
S
, or null if the service isn't
supported.protected boolean isJlcClass(IClassInfo clsInfo)
clsInfo
-
public void setTrendAnalysisCallback(TrendAnalysisCallback cb) throws SpiException
IMemLeak
This likely won't have any effect without Feature.TREND_ANALYSIS
.
setTrendAnalysisCallback
in interface IMemLeak
setTrendAnalysisCallback
in class MemLeakAdapter
cb
- the callback
SpiException
public void setTrendAnalysisEnabled(boolean enabled) throws java.lang.IllegalStateException, SpiException
IMemLeak
Requires Feature.TREND_ANALYSIS
.
setTrendAnalysisEnabled
in interface IMemLeak
setTrendAnalysisEnabled
in class MemLeakAdapter
java.lang.IllegalStateException
- if no callback has been registered
SpiException
public boolean isTrendAnalysisEnabled() throws SpiException
IMemLeak
Requires Feature.TREND_ANALYSIS
to ever return true.
isTrendAnalysisEnabled
in interface IMemLeak
isTrendAnalysisEnabled
in class MemLeakAdapter
SpiException
public IHeapHistogram getHeapHistogram() throws SpiException
IMemLeak
getHeapHistogram
in interface IMemLeak
getHeapHistogram
in class MemLeakAdapter
SpiException
protected abstract com.jrockit.memleak.mlp.ServerRequest createHeapHistogramReq()
ServerRequest
public void setHistogramCutoff(double histogramCutoff) throws java.lang.IllegalArgumentException
IMemLeak
setHistogramCutoff
in interface IMemLeak
setHistogramCutoff
in class MemLeakAdapter
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.IMemLeak.setTrendAnalysisEnabled(boolean)
,
IMemLeak.getHeapHistogram()
public double getHistogramCutoff()
IMemLeak
getHistogramCutoff
in interface IMemLeak
getHistogramCutoff
in class MemLeakAdapter
IMemLeak.setHistogramCutoff(double)
public IPointToTypeInfo[] getTypesPointingTo(ITypeSpecifier type, Policy policy) throws GarbageCollectedException, OperationException, SpiException
IMemLeak
Note that null may be returned, if the policy
allows it.
getTypesPointingTo
in interface IMemLeak
getTypesPointingTo
in class MemLeakAdapter
type
- the type to look forpolicy
- the policy to use
GarbageCollectedException
OperationException
SpiException
protected abstract com.jrockit.memleak.mlp.ServerRequest createTypesPointingToReq(ITypeSpecifier type)
type
-
ServerRequest
(FIXME:or null?)public int getArrayLength(IObjectSpecifier objectSpec) throws GarbageCollectedException, SpiException
IMemLeak
getArrayLength
in interface IMemLeak
getArrayLength
in class MemLeakAdapter
objectSpec
- the array
GarbageCollectedException
SpiException
protected void checkSpecValidity(IObjectSpecifier objectSpec) throws NoSuchIdException, GarbageCollectedException
IObjectSpecifier
is non-null and valid, that
is, doesn't have the IDs OBJECT_ID_INVALID or OBJECT_ID_NULL.
objectSpec
-
NoSuchIdException
- if objectSpec isn't valid.
GarbageCollectedException
- if objectSpec is discarded
java.lang.NullPointerException
- if objectSpec is null.public void enableAllocTracesForClass(ITypeSpecifier type, int bufferSize, int interval, AllocTraceCallback callback) throws java.lang.IllegalStateException, SpiException
IMemLeak
Requires Feature.ALLOCATION_TRACES
.
enableAllocTracesForClass
in interface IMemLeak
enableAllocTracesForClass
in class MemLeakAdapter
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
IMemLeak.setAllocTraceFrequency(int)
protected abstract com.jrockit.memleak.mlp.ServerRequest createEnableAllocTracesForClassReq(ITypeSpecifier type, int bufferSize, int interval)
type
- bufferSize
- interval
-
ServerRequest
public void pollAllocationTraces() throws java.lang.IllegalStateException, SpiException
IMemLeak
pollAllocationTraces
in interface IMemLeak
pollAllocationTraces
in class MemLeakAdapter
java.lang.IllegalStateException
SpiException
public boolean isAllocTracesEnabled() throws SpiException
IMemLeak
Requires Feature.ALLOCATION_TRACES
to ever return true.
isAllocTracesEnabled
in interface IMemLeak
isAllocTracesEnabled
in class MemLeakAdapter
SpiException
public void disableAllocTraces() throws SpiException
IMemLeak
Requires Feature.ALLOCATION_TRACES
to actually do anything.
disableAllocTraces
in interface IMemLeak
disableAllocTraces
in class MemLeakAdapter
SpiException
public void setAllocTraceFrequency(int reportInterval) throws SpiException
IMemLeak
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
.
setAllocTraceFrequency
in interface IMemLeak
setAllocTraceFrequency
in class MemLeakAdapter
reportInterval
- the number of allocations that has to occur before an
allocation trace will be reported
SpiException
public int getAllocTraceFrequency() throws SpiException
IMemLeak
Requires Feature.ALLOCATION_TRACES
for the return value to be of
any significance.
getAllocTraceFrequency
in interface IMemLeak
getAllocTraceFrequency
in class MemLeakAdapter
SpiException
public void doFullGC() throws SpiException
IMemLeak
Requires Feature.GC_TRIGGER
to actually do anything.
doFullGC
in interface IMemLeak
doFullGC
in class MemLeakAdapter
SpiException
public void deleteObjectId(int objectId) throws SpiException
IMemLeak
Requires Feature.DELETE_OBJECT_ID
.
deleteObjectId
in interface IMemLeak
deleteObjectId
in class MemLeakAdapter
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 MemLeakAdapter
objectIds
- an array of object IDs
IResult
whose get()
method
will return nullpublic void destroy() throws java.io.IOException
IMemLeak
destroy
in interface IMemLeak
destroy
in class MemLeakAdapter
java.io.IOException
public void setDisconnectCallback(DisconnectCallback disconnectCallback)
IMemLeak
This likely won't have any effect for implementations that doesn't require any external state.
setDisconnectCallback
in interface IMemLeak
setDisconnectCallback
in class MemLeakAdapter
disconnectCallback
- the callback that handles the exception that was thrown due to
the communication error.public boolean isConnected()
IMemLeak
Implementations that doesn't require any external state should probably return true here (always).
isConnected
in interface IMemLeak
isConnected
in class MemLeakAdapter
protected IPointToTypeInfo parseTypesPointingTo(java.io.DataInputStream dis) throws java.io.IOException, GarbageCollectedException, SpiException
dis
-
IPointToTypeInfo
java.io.IOException
GarbageCollectedException
SpiException
public ITypeHeapInfo<IClassInfo> getLastTypeHeapInfo(IClassInfo classInfo, Policy policy)
getLastTypeHeapInfo
in interface IMemLeak
getLastTypeHeapInfo
in class MemLeakAdapter
policy
- a time stamp in milliseconds
public ITypeHeapInfo<?> getLastTypeHeapInfo(java.lang.String refType, Policy policy)
getLastTypeHeapInfo
in interface IMemLeak
getLastTypeHeapInfo
in class MemLeakAdapter
policy
- a time stamp in milliseconds
protected IHeapHistogram parseHeapUsage(java.io.DataInputStream dis, double histogramCutoff) throws java.io.IOException, SpiException
dis
- histogramCutoff
-
IHeapHistogram
java.io.IOException
SpiException
protected abstract IFieldValue[] parseFieldValues(java.io.DataInputStream dis, boolean onlyStatics) throws java.io.IOException, GarbageCollectedException, SpiException
dis
- 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 abstract IMethodInfo parseMethodInfo(java.io.DataInputStream dis) throws java.io.IOException, GarbageCollectedException, SpiException
dis
-
IMethodInfo
java.io.IOException
SpiException
GarbageCollectedException
protected java.lang.Object readPrimitive(java.io.DataInputStream dis, char type) throws java.io.IOException
type
and return
it in a wrapper.
dis
- type
-
java.io.IOException
java.lang.IllegalArgumentException
- if type is not a char in "ZBCSIJFD".protected abstract ITrace[] parseAllocTraces(java.io.DataInputStream dis) throws java.io.IOException, GarbageCollectedException, SpiException
dis
-
ITrace
array
java.io.IOException
GarbageCollectedException
SpiException
protected abstract IObjectInfo parseObject(java.io.DataInputStream dis) throws java.io.IOException, GarbageCollectedException, SpiException
dis
-
IObjectInfo
java.io.IOException
GarbageCollectedException
SpiException
protected abstract IObjectInfo parseObject(java.io.DataInputStream dis, IClassInfo classInfo) throws java.io.IOException, SpiException
dis
- classInfo
- a IClassInfo
to use for the object, unless already
known or in stream.
IObjectInfo
java.io.IOException
SpiException
protected abstract IObjectSpecifier parseObjectSpec(java.io.DataInputStream dis) throws java.io.IOException, SpiException
dis
-
IObjectSpecifier
or null if the object reference is
null.
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.protected abstract IClassInfo parseClass(java.io.DataInputStream dis) throws java.io.IOException, GarbageCollectedException, SpiException
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 abstract IClassRef parseClassRef(java.io.DataInputStream dis) throws java.io.IOException, SpiException
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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |