Top Description Inners Fields Constructors Methods
io.netty5.buffer.internal

public final Class LeakDetection

extends Object
Class Inheritance
Annotations
@UnstableApi
Imports
io.netty5.buffer.LeakInfo, .LoggingLeakCallback, .MemoryManager, io.netty5.util.SafeCloseable, io.netty5.util.internal.SystemPropertyUtil, .UnstableApi, java.lang.invoke.MethodHandles, .VarHandle, java.util.Collection, .IdentityHashMap, .Iterator, .Map, java.util.concurrent.atomic.AtomicBoolean, java.util.function.Consumer, java.util.stream.Stream

Utility class for the leak detection parts that are static and shared system-wide.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private static final Map<Consumer<LeakInfo>, Integer>
private static final boolean
private static final Integer
private static final VarHandle
pack-priv static volatile int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static VarHandle
public static SafeCloseable
public static void
reportLeak(LifecycleTracer
The life-cycle trace of the leaked object.
tracer
,
String
A human-readable description of the leaked object, that can be used for logging.
leakedObjectDescription
)

Called when a leak is detected.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CALLBACKSback to summary
private static final Map<Consumer<LeakInfo>, Integer> CALLBACKS
ENABLED_BY_PROPERTYback to summary
private static final boolean ENABLED_BY_PROPERTY
INTEGER_ONEback to summary
private static final Integer INTEGER_ONE
LEAK_DETECTION_ENABLED_UPDATERback to summary
private static final VarHandle LEAK_DETECTION_ENABLED_UPDATER
leakDetectionEnabledback to summary
pack-priv static volatile int leakDetectionEnabled

Constructor Detail

LeakDetectionback to summary
private LeakDetection()

Method Detail

getLeakDetectionEnabledUpdaterback to summary
private static VarHandle getLeakDetectionEnabledUpdater() throws NoSuchFieldException, IllegalAccessException
onLeakDetectedback to summary
public static SafeCloseable onLeakDetected(Consumer<LeakInfo> callback)

Internal API for MemoryManager#onLeakDetected(Consumer).

See Also
MemoryManager#onLeakDetected(Consumer)
reportLeakback to summary
public static void reportLeak(LifecycleTracer tracer, String leakedObjectDescription)

Called when a leak is detected. This method will inform all registered on-leak-detected callbacks.

Parameters
tracer:LifecycleTracer

The life-cycle trace of the leaked object.

leakedObjectDescription:String

A human-readable description of the leaked object, that can be used for logging.

io.netty5.buffer.internal back to summary

private final Class LeakDetection.CallbackRemover

extends AtomicBoolean
implements SafeCloseable
Class Inheritance
All Implemented Interfaces
io.netty5.util.SafeCloseable, java.lang.AutoCloseable

Field Summary

Modifier and TypeField and Description
private final Consumer<LeakInfo>
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements io.netty5.util.SafeCloseable.close.

Closes this resource, relinquishing any underlying resources.
Inherited from java.util.concurrent.atomic.AtomicBoolean:
compareAndExchangecompareAndExchangeAcquirecompareAndExchangeReleasecompareAndSetgetgetAcquiregetAndSetgetOpaquegetPlainlazySetsetsetOpaquesetPlainsetReleasetoStringweakCompareAndSetweakCompareAndSetAcquireweakCompareAndSetPlainweakCompareAndSetReleaseweakCompareAndSetVolatile

Field Detail

callbackback to summary
private final Consumer<LeakInfo> callback
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.concurrent.atomic.AtomicBoolean.serialVersionUID.

Constructor Detail

CallbackRemoverback to summary
pack-priv CallbackRemover(Consumer<LeakInfo> callback)

Method Detail

closeback to summary
public void close()

Implements io.netty5.util.SafeCloseable.close.

Doc from java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.

Annotations
@Override
io.netty5.buffer.internal back to summary

private final Class LeakDetection.InternalLeakInfo

extends Object
implements LeakInfo
Class Inheritance
All Implemented Interfaces
io.netty5.buffer.LeakInfo, java.lang.Iterable

Field Summary

Modifier and TypeField and Description
private Collection<LeakInfo.TracePoint>
private final String
private final LifecycleTracer

Constructor Summary

AccessConstructor and Description
pack-priv
InternalLeakInfo(LifecycleTracer tracer, String leakedObjectDescription)

Method Summary

Modifier and TypeMethod and Description
private Collection<LeakInfo.TracePoint>
public Iterator<LeakInfo.TracePoint>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.
public String
objectDescription()

Implements io.netty5.buffer.LeakInfo.objectDescription.

A human-readable description of the object that leaked.
public Stream<LeakInfo.TracePoint>
stream()

Implements io.netty5.buffer.LeakInfo.stream.

Create a Stream of all the TracePoints in this LeakInfo.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cachedTraceback to summary
private Collection<LeakInfo.TracePoint> cachedTrace
leakedObjectDescriptionback to summary
private final String leakedObjectDescription
tracerback to summary
private final LifecycleTracer tracer

Constructor Detail

InternalLeakInfoback to summary
pack-priv InternalLeakInfo(LifecycleTracer tracer, String leakedObjectDescription)

Method Detail

getTracePointsback to summary
private Collection<LeakInfo.TracePoint> getTracePoints()
iteratorback to summary
public Iterator<LeakInfo.TracePoint> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<LeakInfo.TracePoint>

an Iterator.

Annotations
@Override
objectDescriptionback to summary
public String objectDescription()

Implements io.netty5.buffer.LeakInfo.objectDescription.

Doc from io.netty5.buffer.LeakInfo.objectDescription.

A human-readable description of the object that leaked.

Returns:String

A description of the leaked object.

Annotations
@Override
streamback to summary
public Stream<LeakInfo.TracePoint> stream()

Implements io.netty5.buffer.LeakInfo.stream.

Doc from io.netty5.buffer.LeakInfo.stream.

Create a Stream of all the TracePoints in this LeakInfo. The returned Stream does not need to be closed.

Returns:Stream<LeakInfo.TracePoint>

A Stream of TracePoints, covering the life-cycle of the leaked resource.

Annotations
@Override