Class ResourceLeakDetector<T>
java.lang.Object
io.netty.util.ResourceLeakDetector<T>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classstatic interfacestatic enumRepresents the level of resource leak detection.private static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Set<ResourceLeakDetector.DefaultResourceLeak<?>> the collection of active resourcesprivate static final ResourceLeakDetector.Levelprivate static final intprivate static final intprivate static final AtomicReference<String[]> Will be notified once a leak is detected.private static ResourceLeakDetector.Levelprivate static final InternalLoggerprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate final ReferenceQueue<Object> private final String(package private) static final intprivate final intprivate static final int -
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) private voidprotected 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.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.private voidprotected 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.final ResourceLeakTracker<T> 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.
-
Field Details
-
PROP_LEVEL_OLD
- See Also:
-
PROP_LEVEL
- See Also:
-
DEFAULT_LEVEL
-
PROP_TARGET_RECORDS
- See Also:
-
DEFAULT_TARGET_RECORDS
private static final int DEFAULT_TARGET_RECORDS- See Also:
-
PROP_SAMPLING_INTERVAL
- See Also:
-
DEFAULT_SAMPLING_INTERVAL
private static final int DEFAULT_SAMPLING_INTERVAL- See Also:
-
TARGET_RECORDS
private static final int TARGET_RECORDS -
SAMPLING_INTERVAL
static final int SAMPLING_INTERVAL -
level
-
logger
-
allLeaks
the collection of active resources -
refQueue
-
reportedLeaks
-
resourceType
-
samplingInterval
private final int samplingInterval -
leakListener
Will be notified once a leak is detected. -
excludedMethods
-
-
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. Unliketrack(Object), this method always returns a tracker, regardless of the detection settings.- Returns:
- the
ResourceLeakTracker
-
track0
-
clearRefQueue
private void clearRefQueue() -
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.
-
reportLeak
private void reportLeak() -
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).