public class ResourceLeakDetector<T>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private class |
ResourceLeakDetector.DefaultResourceLeak |
static class |
ResourceLeakDetector.Level
Represents the level of resource leak detection.
|
Modifier and Type | Field and Description |
---|---|
private long |
active |
private static ResourceLeakDetector.Level |
DEFAULT_LEVEL |
private static int |
DEFAULT_MAX_RECORDS |
(package private) static int |
DEFAULT_SAMPLING_INTERVAL |
private ResourceLeakDetector.DefaultResourceLeak |
head
the linked list of active resources
|
private long |
leakCheckCnt |
private static ResourceLeakDetector.Level |
level |
private java.util.concurrent.atomic.AtomicBoolean |
loggedTooManyActive |
private static InternalLogger |
logger |
private int |
mask |
private static int |
MAX_RECORDS |
private long |
maxActive |
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 |
private ResourceLeakDetector.DefaultResourceLeak |
tail |
Constructor and Description |
---|
ResourceLeakDetector(java.lang.Class<?> resourceType)
|
ResourceLeakDetector(java.lang.Class<?> resourceType,
int samplingInterval,
long maxActive)
This should not be used directly by users of
ResourceLeakDetector . |
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(int recordsToSkip) |
ResourceLeak |
open(T obj)
Creates a new
ResourceLeak which is expected to be closed via ResourceLeak.close() when the
related resource is deallocated. |
protected void |
reportInstancesLeak(java.lang.String resourceType)
This method is called when instance leaks are detected.
|
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.
|
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 ResourceLeakDetector.DefaultResourceLeak head
private final ResourceLeakDetector.DefaultResourceLeak tail
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 final int mask
private final long maxActive
private long active
private final java.util.concurrent.atomic.AtomicBoolean loggedTooManyActive
private long leakCheckCnt
private static final java.lang.String[] STACK_TRACE_ELEMENT_EXCLUSIONS
@Deprecated public ResourceLeakDetector(java.lang.Class<?> resourceType)
@Deprecated public ResourceLeakDetector(java.lang.String resourceType)
public ResourceLeakDetector(java.lang.Class<?> resourceType, int samplingInterval, long maxActive)
ResourceLeakDetector
.
Please use ResourceLeakDetectorFactory.newResourceLeakDetector(Class)
or ResourceLeakDetectorFactory.newResourceLeakDetector(Class, int, long)
@Deprecated public ResourceLeakDetector(java.lang.String resourceType, int samplingInterval, long maxActive)
@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()
public final ResourceLeak open(T obj)
ResourceLeak
which is expected to be closed via ResourceLeak.close()
when the
related resource is deallocated.ResourceLeak
or null
private void reportLeak(ResourceLeakDetector.Level level)
protected void reportTracedLeak(java.lang.String resourceType, java.lang.String records)
protected void reportUntracedLeak(java.lang.String resourceType)
protected void reportInstancesLeak(java.lang.String resourceType)
static java.lang.String newRecord(int recordsToSkip)