public class ResourceLeakDetector<T>
extends java.lang.Object
限定符和类型 | 类和说明 |
---|---|
static interface |
ResourceLeakDetector.LeakListener |
static class |
ResourceLeakDetector.Level
Represents the level of resource leak detection.
|
构造器和说明 |
---|
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)
已过时。
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)
|
限定符和类型 | 方法和说明 |
---|---|
static void |
addExclusions(java.lang.Class clz,
java.lang.String... methodNames) |
protected java.lang.Object |
getInitialHint(java.lang.String resourceType)
Create a hint object to be attached to an object tracked by this record.
|
static ResourceLeakDetector.Level |
getLevel()
Returns the current resource leak detection level.
|
static boolean |
isEnabled()
Returns
true if resource leak detection is enabled. |
protected boolean |
needReport()
When the return value is
true , reportTracedLeak(java.lang.String, java.lang.String) and reportUntracedLeak(java.lang.String)
will be called once a leak is detected, otherwise not. |
ResourceLeak |
open(T obj)
已过时。
use
track(Object) |
protected void |
reportInstancesLeak(java.lang.String resourceType)
已过时。
This method will no longer be invoked by
ResourceLeakDetector . |
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)
已过时。
Use
setLevel(Level) instead. |
void |
setLeakListener(ResourceLeakDetector.LeakListener leakListener)
Set leak listener.
|
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. |
ResourceLeakTracker<T> |
trackForcibly(T obj)
Creates a new
ResourceLeakTracker which is expected to be closed via
ResourceLeakTracker.close(Object) when the related resource is deallocated. |
@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
public ResourceLeakTracker<T> trackForcibly(T obj)
ResourceLeakTracker
which is expected to be closed via
ResourceLeakTracker.close(Object)
when the related resource is deallocated.
Unlike track(Object)
, this method always returns a tracker, regardless
of the detection settings.ResourceLeakTracker
protected boolean needReport()
true
, reportTracedLeak(java.lang.String, java.lang.String)
and reportUntracedLeak(java.lang.String)
will be called once a leak is detected, otherwise not.true
to enable leak reporting.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
.protected java.lang.Object getInitialHint(java.lang.String resourceType)
ResourceLeakTracker.record(Object)
, will be printed alongside the stack trace of the
creation of the resource.public void setLeakListener(ResourceLeakDetector.LeakListener leakListener)
public static void addExclusions(java.lang.Class clz, java.lang.String... methodNames)