public class ResourceLeakDetector<T>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private class |
ResourceLeakDetector.DefaultResourceLeak |
private static class |
ResourceLeakDetector.LeakEntry |
static class |
ResourceLeakDetector.Level
Represents the level of resource leak detection.
|
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.ConcurrentMap<ResourceLeakDetector.DefaultResourceLeak,ResourceLeakDetector.LeakEntry> |
allLeaks
the collection of active resources
|
private static ResourceLeakDetector.Level |
DEFAULT_LEVEL |
private static int |
DEFAULT_MAX_RECORDS |
(package private) static int |
DEFAULT_SAMPLING_INTERVAL |
private static ResourceLeakDetector.Level |
level |
private static InternalLogger |
logger |
private static int |
MAX_RECORDS |
private static java.lang.String |
PROP_LEVEL |
private static java.lang.String |
PROP_LEVEL_OLD |
private static java.lang.String |
PROP_MAX_RECORDS |
private java.lang.ref.ReferenceQueue<java.lang.Object> |
refQueue |
private java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.Boolean> |
reportedLeaks |
private java.lang.String |
resourceType |
private int |
samplingInterval |
private static java.lang.String[] |
STACK_TRACE_ELEMENT_EXCLUSIONS |
Constructor and Description |
---|
ResourceLeakDetector(java.lang.Class<?> resourceType)
|
ResourceLeakDetector(java.lang.Class<?> resourceType,
int samplingInterval)
This should not be used directly by users of
ResourceLeakDetector . |
ResourceLeakDetector(java.lang.Class<?> resourceType,
int samplingInterval,
long maxActive)
Deprecated.
Use
ResourceLeakDetector(Class, int) .
This should not be used directly by users of |
ResourceLeakDetector(java.lang.String resourceType)
|
ResourceLeakDetector(java.lang.String resourceType,
int samplingInterval,
long maxActive)
|
Modifier and Type | Method and Description |
---|---|
static ResourceLeakDetector.Level |
getLevel()
Returns the current resource leak detection level.
|
static boolean |
isEnabled()
Returns
true if resource leak detection is enabled. |
(package private) static java.lang.String |
newRecord(java.lang.Object hint,
int recordsToSkip) |
ResourceLeak |
open(T obj)
Deprecated.
use
track(Object) |
protected void |
reportInstancesLeak(java.lang.String resourceType)
Deprecated.
This method will no longer be invoked by
ResourceLeakDetector . |
private void |
reportLeak(ResourceLeakDetector.Level level) |
protected void |
reportTracedLeak(java.lang.String resourceType,
java.lang.String records)
This method is called when a traced leak is detected.
|
protected void |
reportUntracedLeak(java.lang.String resourceType)
This method is called when an untraced leak is detected.
|
static void |
setEnabled(boolean enabled)
Deprecated.
Use
setLevel(Level) instead. |
static void |
setLevel(ResourceLeakDetector.Level level)
Sets the resource leak detection level.
|
ResourceLeakTracker<T> |
track(T obj)
Creates a new
ResourceLeakTracker which is expected to be closed via
ResourceLeakTracker.close(Object) when the related resource is deallocated. |
private ResourceLeakDetector.DefaultResourceLeak |
track0(T obj) |
private static final java.lang.String PROP_LEVEL_OLD
private static final java.lang.String PROP_LEVEL
private static final ResourceLeakDetector.Level DEFAULT_LEVEL
private static final java.lang.String PROP_MAX_RECORDS
private static final int DEFAULT_MAX_RECORDS
private static final int MAX_RECORDS
private static ResourceLeakDetector.Level level
private static final InternalLogger logger
static final int DEFAULT_SAMPLING_INTERVAL
private final java.util.concurrent.ConcurrentMap<ResourceLeakDetector.DefaultResourceLeak,ResourceLeakDetector.LeakEntry> allLeaks
private final java.lang.ref.ReferenceQueue<java.lang.Object> refQueue
private final java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.Boolean> reportedLeaks
private final java.lang.String resourceType
private final int samplingInterval
private static final java.lang.String[] STACK_TRACE_ELEMENT_EXCLUSIONS
@Deprecated public ResourceLeakDetector(java.lang.Class<?> resourceType)
@Deprecated public ResourceLeakDetector(java.lang.String resourceType)
@Deprecated public ResourceLeakDetector(java.lang.Class<?> resourceType, int samplingInterval, long maxActive)
ResourceLeakDetector(Class, int)
.
This should not be used directly by users of ResourceLeakDetector
.
Please use ResourceLeakDetectorFactory.newResourceLeakDetector(Class)
or ResourceLeakDetectorFactory.newResourceLeakDetector(Class, int, long)
maxActive
- This is deprecated and will be ignored.public ResourceLeakDetector(java.lang.Class<?> resourceType, int samplingInterval)
ResourceLeakDetector
.
Please use ResourceLeakDetectorFactory.newResourceLeakDetector(Class)
or ResourceLeakDetectorFactory.newResourceLeakDetector(Class, int, long)
@Deprecated public ResourceLeakDetector(java.lang.String resourceType, int samplingInterval, long maxActive)
maxActive
- This is deprecated and will be ignored.@Deprecated public static void setEnabled(boolean enabled)
setLevel(Level)
instead.public static boolean isEnabled()
true
if resource leak detection is enabled.public static void setLevel(ResourceLeakDetector.Level level)
public static ResourceLeakDetector.Level getLevel()
@Deprecated public final ResourceLeak open(T obj)
track(Object)
ResourceLeak
which is expected to be closed via ResourceLeak.close()
when the
related resource is deallocated.ResourceLeak
or null
public final ResourceLeakTracker<T> track(T obj)
ResourceLeakTracker
which is expected to be closed via
ResourceLeakTracker.close(Object)
when the related resource is deallocated.ResourceLeakTracker
or null
private ResourceLeakDetector.DefaultResourceLeak track0(T obj)
private void reportLeak(ResourceLeakDetector.Level level)
protected void reportTracedLeak(java.lang.String resourceType, java.lang.String records)
protected void reportUntracedLeak(java.lang.String resourceType)
@Deprecated protected void reportInstancesLeak(java.lang.String resourceType)
ResourceLeakDetector
.static java.lang.String newRecord(java.lang.Object hint, int recordsToSkip)