Modifier and Type | Class and Description |
---|---|
private static class | ResourceLeakDetector.
Deprecated
as a consequence of
ResourceLeak being deprecated.
|
public static interface | |
public static enum | ResourceLeakDetector.
Represents the level of resource leak detection. |
private static class |
Modifier and Type | Field and Description |
---|---|
private final Set | allLeaks
the collection of active resources |
private static final ResourceLeakDetector. | |
private static final int | |
private static final int | |
private static final AtomicReference | |
private volatile ResourceLeakDetector. | leakListener
Will be notified once a leak is detected. |
private static ResourceLeakDetector. | |
private static final InternalLogger | |
private static final String | |
private static final String | |
private static final String | |
private static final String | |
private final ReferenceQueue | |
private final Set | |
private final String | |
pack-priv static final int | |
private final int | |
private static final int |
Access | Constructor and Description |
---|---|
public | ResourceLeakDetector(Class<?> resourceType)
|
public | ResourceLeakDetector(String resourceType)
|
public | ResourceLeakDetector(Class<?> resourceType, int samplingInterval, long
This is deprecated and will be ignored. maxActive)
Deprecated
Use
ResourceLeakDetector#ResourceLeakDetector(Class, int) .
|
public | ResourceLeakDetector(Class<?> resourceType, int samplingInterval)
This should not be used directly by users of |
public | ResourceLeakDetector(String resourceType, int samplingInterval, long
This is deprecated and will be ignored. maxActive)
|
Modifier and Type | Method and Description |
---|---|
public static void | |
private void | |
protected Object | getInitialHint(String resourceType)
Create a hint object to be attached to an object tracked by this record. |
public static ResourceLeakDetector. | |
public static boolean | |
protected boolean | Returns: true to enable leak reporting.When the return value is |
public final ResourceLeak | open(T obj)
Deprecated
use
Creates a new track(Object)
ResourceLeak which is expected to be closed via ResourceLeak#close() when the
related resource is deallocated.
|
protected void | reportInstancesLeak(String resourceType)
Deprecated
This method will no longer be invoked by
ResourceLeakDetector .
|
private void | |
protected void | reportTracedLeak(String resourceType, String records)
This method is called when a traced leak is detected. |
protected void | |
public static void | |
public void | |
public static void | |
public final ResourceLeakTracker | track(T obj)
Creates a new |
private ResourceLeakDetector. | track0(T obj, boolean force)
Deprecated
as a consequence of
ResourceLeakDetector.DefaultResourceLeak being deprecated.
|
public ResourceLeakTracker | Returns: theResourceLeakTracker Creates a new |
allLeaks | back to summary |
---|---|
private final Set<ResourceLeakDetector. the collection of active resources |
DEFAULT_LEVEL | back to summary |
---|---|
private static final ResourceLeakDetector. |
DEFAULT_SAMPLING_INTERVAL | back to summary |
---|---|
private static final int DEFAULT_SAMPLING_INTERVAL |
DEFAULT_TARGET_RECORDS | back to summary |
---|---|
private static final int DEFAULT_TARGET_RECORDS |
excludedMethods | back to summary |
---|---|
private static final AtomicReference<String[]> excludedMethods |
leakListener | back to summary |
---|---|
private volatile ResourceLeakDetector. Will be notified once a leak is detected. |
level | back to summary |
---|---|
private static ResourceLeakDetector. |
logger | back to summary |
---|---|
private static final InternalLogger logger |
PROP_LEVEL | back to summary |
---|---|
private static final String PROP_LEVEL |
PROP_LEVEL_OLD | back to summary |
---|---|
private static final String PROP_LEVEL_OLD |
PROP_SAMPLING_INTERVAL | back to summary |
---|---|
private static final String PROP_SAMPLING_INTERVAL |
PROP_TARGET_RECORDS | back to summary |
---|---|
private static final String PROP_TARGET_RECORDS |
refQueue | back to summary |
---|---|
private final ReferenceQueue<Object> refQueue |
reportedLeaks | back to summary |
---|---|
private final Set<String> reportedLeaks |
resourceType | back to summary |
---|---|
private final String resourceType |
SAMPLING_INTERVAL | back to summary |
---|---|
pack-priv static final int SAMPLING_INTERVAL |
samplingInterval | back to summary |
---|---|
private final int samplingInterval |
TARGET_RECORDS | back to summary |
---|---|
private static final int TARGET_RECORDS |
ResourceLeakDetector | back to summary |
---|---|
public ResourceLeakDetector(Class<?> resourceType)
|
ResourceLeakDetector | back to summary |
---|---|
public ResourceLeakDetector(String resourceType)
|
ResourceLeakDetector | back to summary |
---|---|
public ResourceLeakDetector(Class<?> resourceType, int samplingInterval, long maxActive)
Deprecated Use
This should not be used directly by users of
|
ResourceLeakDetector | back to summary |
---|---|
public ResourceLeakDetector(Class<?> resourceType, int samplingInterval) This should not be used directly by users of
|
ResourceLeakDetector | back to summary |
---|---|
public ResourceLeakDetector(String resourceType, int samplingInterval, long maxActive)
|
addExclusions | back to summary |
---|---|
public static void addExclusions(Class<T> clz, String... methodNames) |
clearRefQueue | back to summary |
---|---|
private void clearRefQueue() |
getInitialHint | back to summary |
---|---|
protected Object getInitialHint(String resourceType) Create a hint object to be attached to an object tracked by this record. Similar to the additional information
supplied to |
getLevel | back to summary |
---|---|
public static ResourceLeakDetector. Returns the current resource leak detection level. |
isEnabled | back to summary |
---|---|
public static boolean isEnabled() Returns |
needReport | back to summary |
---|---|
protected boolean needReport() When the return value is
|
open | back to summary |
---|---|
public final ResourceLeak open(T obj)
Deprecated use Creates a new
|
reportInstancesLeak | back to summary |
---|---|
protected void reportInstancesLeak(String resourceType)
Deprecated This method will no longer be invoked by
|
reportLeak | back to summary |
---|---|
private void reportLeak() |
reportTracedLeak | back to summary |
---|---|
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 | back to summary |
---|---|
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. |
setEnabled | back to summary |
---|---|
public static void setEnabled(boolean enabled)
Deprecated Use
|
setLeakListener | back to summary |
---|---|
public void setLeakListener(ResourceLeakDetector. Set leak listener. Previous listener will be replaced. |
setLevel | back to summary |
---|---|
public static void setLevel(ResourceLeakDetector. Sets the resource leak detection level. |
track | back to summary |
---|---|
public final ResourceLeakTracker Creates a new
|
track0 | back to summary |
---|---|
private ResourceLeakDetector. Deprecated as a consequence of
|
trackForcibly | back to summary |
---|---|
public ResourceLeakTracker Creates a new
|
Deprecated
as a consequence of ResourceLeak
being deprecated. See corresponding docs for further information.
Modifier and Type | Field and Description |
---|---|
private final Set | |
private volatile int | |
private static final AtomicIntegerFieldUpdater | |
private volatile ResourceLeakDetector. | |
private static final AtomicReferenceFieldUpdater | |
private final int |
Access | Constructor and Description |
---|---|
pack-priv | DefaultResourceLeak(Object referent, ReferenceQueue<Object> refQueue, Set<ResourceLeakDetector.
|
Modifier and Type | Method and Description |
---|---|
public boolean | close()
Implements io. ResourceLeakDetector does not warn about leaked resources.
|
public boolean | close(T trackedObject)
Implements io. ResourceLeakTracker does not warn about leaked resources.
|
pack-priv boolean | |
private String | |
pack-priv String | |
private static void | reachabilityFence0(Object
the reference. If ref)null , this method has no effect.Ensures that the object referenced by the given reference remains strongly reachable, regardless of any prior actions of the program that might otherwise cause the object to become unreachable; thus, the referenced object is not reclaimable by garbage collection at least until after the invocation of this method. |
public void | record()
Implements io. ResourceLeakDetector can tell where the leaked
resource was accessed lastly.
|
public void | record(Object hint)
Implements io. ResourceLeakDetector can tell where the leaked resource was accessed lastly.
|
private void | |
public String |
allLeaks | back to summary |
---|---|
private final Set<ResourceLeakDetector. |
droppedRecords | back to summary |
---|---|
private volatile int droppedRecords
|
droppedRecordsUpdater | back to summary |
---|---|
private static final AtomicIntegerFieldUpdater<ResourceLeakDetector.
|
head | back to summary |
---|---|
private volatile ResourceLeakDetector.
|
headUpdater | back to summary |
---|---|
private static final AtomicReferenceFieldUpdater<ResourceLeakDetector.
|
trackedHash | back to summary |
---|---|
private final int trackedHash |
DefaultResourceLeak | back to summary |
---|---|
pack-priv DefaultResourceLeak(Object referent, ReferenceQueue<Object> refQueue, Set<ResourceLeakDetector. |
close | back to summary |
---|---|
public boolean close() Implements io. Doc from io. Close the leak so that
|
close | back to summary |
---|---|
public boolean close(T trackedObject) Implements io. Doc from io. Close the leak so that
|
dispose | back to summary |
---|---|
pack-priv boolean dispose() |
generateReport | back to summary |
---|---|
private String generateReport(ResourceLeakDetector. |
getReportAndClearRecords | back to summary |
---|---|
pack-priv String getReportAndClearRecords() |
reachabilityFence0 | back to summary |
---|---|
private static void reachabilityFence0(Object ref) Ensures that the object referenced by the given reference remains strongly reachable, regardless of any prior actions of the program that might otherwise cause the object to become unreachable; thus, the referenced object is not reclaimable by garbage collection at least until after the invocation of this method. Recent versions of the JDK have a nasty habit of prematurely deciding objects are unreachable. see: https://stackoverflow.com/questions/26642153/finalize-called-on-strongly-reachable-object-in-java-8 The Java 9 method Reference.reachabilityFence offers a solution to this problem. This method is always implemented as a synchronization on
|
record | back to summary |
---|---|
public void record() Implements io. Doc from io. Records the caller's current stack trace so that the
|
record | back to summary |
---|---|
public void record(Object hint) Implements io. Doc from io. Records the caller's current stack trace and the specified additional arbitrary information
so that the
|
record0 | back to summary |
---|---|
private void record0(Object hint) This method works by exponentially backing off as more records are present in the stack. Each record has a 1 / 2^n chance of dropping the top most record and replacing it with itself. This has a number of convenient properties:
TARGET_RECORDS accesses, backoff occurs. This matches typical access patterns,
where there are either a high number of accesses (i.e. a cached buffer), or low (an ephemeral buffer), but
not many in between.
The use of atomics avoids serializing a high number of accesses, when most of the records will be thrown
away. High contention only happens when there are very few existing records, which is only likely when the
object isn't shared! If this is a problem, the loop can be aborted and the record dropped, because another
thread won the race.
|
toString | back to summary |
---|---|
public String toString() Overrides java. Doc from java. Returns a string representation of the object. |
Modifier and Type | Method and Description |
---|---|
public void |
onLeak | back to summary |
---|---|
public void onLeak(String resourceType, String records) Will be called once a leak is detected. |
Modifier and Type | Field and Description |
---|---|
public static final ResourceLeakDetector. | ADVANCED
Enables advanced sampling resource leak detection which reports where the leaked object was accessed recently at the cost of high overhead. |
public static final ResourceLeakDetector. | DISABLED
Disables resource leak detection. |
public static final ResourceLeakDetector. | PARANOID
Enables paranoid resource leak detection which reports where the leaked object was accessed recently, at the cost of the highest possible overhead (for testing purposes only). |
public static final ResourceLeakDetector. | SIMPLE
Enables simplistic sampling resource leak detection which reports there is a leak or not, at the cost of small overhead (default). |
Access | Constructor and Description |
---|---|
private |
Modifier and Type | Method and Description |
---|---|
pack-priv static ResourceLeakDetector. | Returns: corresponding level or SIMPLE level in case of no match.- level string : DISABLED, SIMPLE, ADVANCED, PARANOID. Ignores case. levelStr)Returns level based on string value. |
public static ResourceLeakDetector. | |
public static ResourceLeakDetector. |
ADVANCED | back to summary |
---|---|
public static final ResourceLeakDetector. Enables advanced sampling resource leak detection which reports where the leaked object was accessed recently at the cost of high overhead. |
DISABLED | back to summary |
---|---|
public static final ResourceLeakDetector. Disables resource leak detection. |
PARANOID | back to summary |
---|---|
public static final ResourceLeakDetector. Enables paranoid resource leak detection which reports where the leaked object was accessed recently, at the cost of the highest possible overhead (for testing purposes only). |
SIMPLE | back to summary |
---|---|
public static final ResourceLeakDetector. Enables simplistic sampling resource leak detection which reports there is a leak or not, at the cost of small overhead (default). |
Level | back to summary |
---|---|
private Level() |
parseLevel | back to summary |
---|---|
pack-priv static ResourceLeakDetector. Returns level based on string value. Accepts also string that represents ordinal number of enum.
|
valueOf | back to summary |
---|---|
public static ResourceLeakDetector. |
values | back to summary |
---|---|
public static ResourceLeakDetector. |
Modifier and Type | Field and Description |
---|---|
private static final ResourceLeakDetector. | |
private final String | |
private final ResourceLeakDetector. | |
private final int | |
private static final long |
Access | Constructor and Description |
---|---|
pack-priv | |
pack-priv | |
private |
Modifier and Type | Method and Description |
---|---|
public String |
BOTTOM | back to summary |
---|---|
private static final ResourceLeakDetector. |
hintString | back to summary |
---|---|
private final String hintString |
next | back to summary |
---|---|
private final ResourceLeakDetector. |
pos | back to summary |
---|---|
private final int pos |
serialVersionUID | back to summary |
---|---|
private static final long serialVersionUID |
TraceRecord | back to summary |
---|---|
pack-priv TraceRecord(ResourceLeakDetector. |
TraceRecord | back to summary |
---|---|
pack-priv TraceRecord(ResourceLeakDetector. |
TraceRecord | back to summary |
---|---|
private TraceRecord() |
toString | back to summary |
---|---|
public String toString() Overrides java. Doc from java. Returns a short description of this throwable. The result is the concatenation of:
getLocalizedMessage returns null , then just
the class name is returned.
|