Package io.netty.util
Class ResourceLeakDetector<T>
- java.lang.Object
-
- io.netty.util.ResourceLeakDetector<T>
-
public class ResourceLeakDetector<T> extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ResourceLeakDetector.Level
Represents the level of resource leak detection.
-
Constructor Summary
Constructors Constructor Description ResourceLeakDetector(Class<?> resourceType)
ResourceLeakDetector(Class<?> resourceType, int samplingInterval)
This should not be used directly by users ofResourceLeakDetector
.ResourceLeakDetector(Class<?> resourceType, int samplingInterval, long maxActive)
Deprecated.ResourceLeakDetector(String resourceType)
ResourceLeakDetector(String resourceType, int samplingInterval, long maxActive)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
addExclusions(Class clz, String... methodNames)
static ResourceLeakDetector.Level
getLevel()
Returns the current resource leak detection level.static boolean
isEnabled()
Returnstrue
if resource leak detection is enabled.protected boolean
needReport()
When the return value istrue
,reportTracedLeak(java.lang.String, java.lang.String)
andreportUntracedLeak(java.lang.String)
will be called once a leak is detected, otherwise not.ResourceLeak
open(T obj)
Deprecated.usetrack(Object)
protected void
reportInstancesLeak(String resourceType)
Deprecated.This method will no longer be invoked byResourceLeakDetector
.protected void
reportTracedLeak(String resourceType, String records)
This method is called when a traced leak is detected.protected void
reportUntracedLeak(String resourceType)
This method is called when an untraced leak is detected.static void
setEnabled(boolean enabled)
Deprecated.UsesetLevel(Level)
instead.static void
setLevel(ResourceLeakDetector.Level level)
Sets the resource leak detection level.ResourceLeakTracker<T>
track(T obj)
Creates a newResourceLeakTracker
which is expected to be closed viaResourceLeakTracker.close(Object)
when the related resource is deallocated.
-
-
-
Constructor Detail
-
ResourceLeakDetector
@Deprecated public ResourceLeakDetector(Class<?> resourceType)
-
ResourceLeakDetector
@Deprecated public ResourceLeakDetector(String resourceType)
-
ResourceLeakDetector
@Deprecated public ResourceLeakDetector(Class<?> resourceType, int samplingInterval, long maxActive)
Deprecated.UseResourceLeakDetector(Class, int)
.This should not be used directly by users of
ResourceLeakDetector
. Please useResourceLeakDetectorFactory.newResourceLeakDetector(Class)
orResourceLeakDetectorFactory.newResourceLeakDetector(Class, int, long)
- Parameters:
maxActive
- This is deprecated and will be ignored.
-
ResourceLeakDetector
public ResourceLeakDetector(Class<?> resourceType, int samplingInterval)
This should not be used directly by users ofResourceLeakDetector
. Please useResourceLeakDetectorFactory.newResourceLeakDetector(Class)
orResourceLeakDetectorFactory.newResourceLeakDetector(Class, int, long)
-
ResourceLeakDetector
@Deprecated public ResourceLeakDetector(String resourceType, int samplingInterval, long maxActive)
- Parameters:
maxActive
- This is deprecated and will be ignored.
-
-
Method Detail
-
setEnabled
@Deprecated public static void setEnabled(boolean enabled)
Deprecated.UsesetLevel(Level)
instead.
-
isEnabled
public static boolean isEnabled()
Returnstrue
if resource leak detection is enabled.
-
setLevel
public static void setLevel(ResourceLeakDetector.Level level)
Sets the resource leak detection level.
-
getLevel
public static ResourceLeakDetector.Level getLevel()
Returns the current resource leak detection level.
-
open
@Deprecated public final ResourceLeak open(T obj)
Deprecated.usetrack(Object)
Creates a newResourceLeak
which is expected to be closed viaResourceLeak.close()
when the related resource is deallocated.- Returns:
- the
ResourceLeak
ornull
-
track
public final ResourceLeakTracker<T> track(T obj)
Creates a newResourceLeakTracker
which is expected to be closed viaResourceLeakTracker.close(Object)
when the related resource is deallocated.- Returns:
- the
ResourceLeakTracker
ornull
-
needReport
protected boolean needReport()
When the return value istrue
,reportTracedLeak(java.lang.String, java.lang.String)
andreportUntracedLeak(java.lang.String)
will be called once a leak is detected, otherwise not.- Returns:
true
to enable leak reporting.
-
reportTracedLeak
protected void reportTracedLeak(String resourceType, String records)
This method is called when a traced leak is detected. It can be overridden for tracking how many times leaks have been detected.
-
reportUntracedLeak
protected void reportUntracedLeak(String resourceType)
This method is called when an untraced leak is detected. It can be overridden for tracking how many times leaks have been detected.
-
reportInstancesLeak
@Deprecated protected void reportInstancesLeak(String resourceType)
Deprecated.This method will no longer be invoked byResourceLeakDetector
.
-
-