Package org.apache.ivy.util
Class MemoryUtil
java.lang.Object
org.apache.ivy.util.MemoryUtil
Memory related utilities.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidgc()static longReturns the currently used memory, after calling garbage collector and waiting enough to get maximal chance it is actually called.static voidstatic longReturns the approximate size of a default instance of the given class.
-
Field Details
-
SAMPLING_SIZE
private static final int SAMPLING_SIZE- See Also:
-
SLEEP_TIME
private static final int SLEEP_TIME- See Also:
-
-
Constructor Details
-
MemoryUtil
private MemoryUtil()
-
-
Method Details
-
sizeOf
Returns the approximate size of a default instance of the given class.- Parameters:
clazz- the class to evaluate.- Returns:
- the estimated size of instance, in bytes.
-
getUsedMemory
public static long getUsedMemory()Returns the currently used memory, after calling garbage collector and waiting enough to get maximal chance it is actually called. But sinceRuntime.gc()is only advisory, results returned by this method should be treated as rough approximation only.- Returns:
- the currently used memory, in bytes.
-
gc
private static void gc() -
main
- Throws:
ClassNotFoundException
-