public final class MemoryUtil
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static long |
getUsedMemory()
Returns the currently used memory, after calling garbage collector and waiting enough to get
maximal chance it is actually called.
|
static void |
main(java.lang.String[] args) |
static long |
sizeOf(java.lang.Class clazz)
Returns the approximate size of a default instance of the given class.
|
public static long sizeOf(java.lang.Class clazz)
clazz
- the class to evaluate.public static long getUsedMemory()
Runtime.gc()
is only advisory,
results returned by this method should be treated as rough approximation only.public static void main(java.lang.String[] args) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException