public class MemoryLeakUtil
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
checkAllTrackedObjects(boolean verbose,
boolean stopTrackingCollectedObjects)
Checks whether all tracked objects have been garbage collected, logging summary information
including how many have been collected and how many have not.
|
static boolean |
isTrackedObjectCollected(java.lang.String key,
boolean stopTrackingIfCollected)
Checks whether a particular tracked object has been garbage collected.
|
static java.lang.String |
trackObject(java.lang.String tag,
java.lang.Object object)
Tracks the given Object by saving a WeakReference to it so that we can check later if it has
been garbage collected.
|
public static java.lang.String trackObject(java.lang.String tag, java.lang.Object object)
tag
- the tag for the Objectobject
- the Object to trackpublic static boolean isTrackedObjectCollected(java.lang.String key, boolean stopTrackingIfCollected)
key
- a key returned from trackObject(java.lang.String, java.lang.Object)
stopTrackingIfCollected
- whether to stop tracking the object if it has been garbage
collectedjava.lang.IllegalArgumentException
- if the key is not validpublic static void checkAllTrackedObjects(boolean verbose, boolean stopTrackingCollectedObjects)
verbose
- whether to log details about each tracked objectstopTrackingCollectedObjects
- whether to stop tracking objects that have been garbage
collected