org.apache.ivy.util

Class MemoryUtil

public final class MemoryUtil extends Object

Memory related utilities.
Method Summary
static longgetUsedMemory()
Returns the currently used memory, after calling garbage collector and waiting enough to get maximal chance it is actually called.
static voidmain(String[] args)
static longsizeOf(Class clazz)
Returns the approximate size of a default instance of the given class.

Method Detail

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 since Runtime#gc() is only advisory, results returned by this method should be treated as rough approximation only.

Returns: the currently used memory, in bytes.

main

public static void main(String[] args)

sizeOf

public static long sizeOf(Class clazz)
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.