public class InstanceCounter extends Object
Example: Put the following line into the class you want counted:
private final InstanceCounter instanceCounter = new InstanceCounter<>(this);
Constructor and Description |
---|
InstanceCounter(Object counted)
triggers instance counting of the specified
|
Modifier and Type | Method and Description |
---|---|
static int |
getInstanceCount(Class<?> countedType,
long timeout)
Returns instance count of a particular class.
|
static Set<WeakReference<?>> |
getInstances(Class<?> countedType,
long timeout)
gets actual references to counted objects
|
public InstanceCounter(Object counted)
counted
- object to be countedpublic static int getInstanceCount(Class<?> countedType, long timeout)
countedType
- timeout
- in milliseconds to wait to collect removed instancespublic static Set<WeakReference<?>> getInstances(Class<?> countedType, long timeout)
countedType
- timeout
- in millisecondsCopyright © 2021. All rights reserved.