Class ResourceLeakDetector<T>
java.lang.Object
io.netty.util.ResourceLeakDetector<T>
- Direct Known Subclasses:
LeakPresenceDetector
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic enumRepresents the level of resource leak detection. -
Constructor Summary
ConstructorsConstructorDescriptionResourceLeakDetector(Class<?> resourceType) Deprecated.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
Modifier and TypeMethodDescriptionstatic voidaddExclusions(Class clz, String... methodNames) protected ObjectgetInitialHint(String resourceType) Create a hint object to be attached to an object tracked by this record.static ResourceLeakDetector.LevelgetLevel()Returns the current resource leak detection level.static booleanReturnstrueif resource leak detection is enabled.booleanCheck whetherResourceLeakTracker.record()does anything for this detector.protected booleanWhen the return value istrue,reportTracedLeak(String, String)andreportUntracedLeak(String)will be called once a leak is detected, otherwise not.final ResourceLeakDeprecated.usetrack(Object)protected voidreportInstancesLeak(String resourceType) Deprecated.This method will no longer be invoked byResourceLeakDetector.protected voidreportTracedLeak(String resourceType, String records) This method is called when a traced leak is detected.protected voidreportUntracedLeak(String resourceType) This method is called when an untraced leak is detected.static voidsetEnabled(boolean enabled) Deprecated.UsesetLevel(Level)instead.voidsetLeakListener(ResourceLeakDetector.LeakListener leakListener) Set leak listener.static voidSets the resource leak detection level.Creates a newResourceLeakTrackerwhich is expected to be closed viaResourceLeakTracker.close(Object)when the related resource is deallocated.trackForcibly(T obj) Creates a newResourceLeakTrackerwhich is expected to be closed viaResourceLeakTracker.close(Object)when the related resource is deallocated.
-
Constructor Details
-
ResourceLeakDetector
-
ResourceLeakDetector
-
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
This should not be used directly by users ofResourceLeakDetector. Please useResourceLeakDetectorFactory.newResourceLeakDetector(Class)orResourceLeakDetectorFactory.newResourceLeakDetector(Class, int, long) -
ResourceLeakDetector
- Parameters:
maxActive- This is deprecated and will be ignored.
-
-
Method Details
-
setEnabled
Deprecated.UsesetLevel(Level)instead. -
isEnabled
public static boolean isEnabled()Returnstrueif resource leak detection is enabled. -
setLevel
Sets the resource leak detection level. -
getLevel
Returns the current resource leak detection level. -
open
Deprecated.usetrack(Object)Creates a newResourceLeakwhich is expected to be closed viaResourceLeak.close()when the related resource is deallocated.- Returns:
- the
ResourceLeakornull
-
track
Creates a newResourceLeakTrackerwhich is expected to be closed viaResourceLeakTracker.close(Object)when the related resource is deallocated.- Returns:
- the
ResourceLeakTrackerornull
-
trackForcibly
Creates a newResourceLeakTrackerwhich is expected to be closed viaResourceLeakTracker.close(Object)when the related resource is deallocated.Unlike
track(Object), this method always returns a tracker, regardless of the detection settings.- Returns:
- the
ResourceLeakTracker
-
isRecordEnabled
public boolean isRecordEnabled()Check whetherResourceLeakTracker.record()does anything for this detector.- Returns:
trueifResourceLeakTracker.record()should be called
-
needReport
protected boolean needReport()When the return value istrue,reportTracedLeak(String, String)andreportUntracedLeak(String)will be called once a leak is detected, otherwise not.- Returns:
trueto enable leak reporting.
-
reportTracedLeak
-
reportUntracedLeak
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.This method will no longer be invoked byResourceLeakDetector. -
getInitialHint
Create a hint object to be attached to an object tracked by this record. Similar to the additional information supplied toResourceLeakTracker.record(Object), will be printed alongside the stack trace of the creation of the resource. -
setLeakListener
Set leak listener. Previous listener will be replaced. -
addExclusions
-
ResourceLeakDetectorFactory.newResourceLeakDetector(Class, int, long).