jcontrol.system
Class Memory

java.lang.Object
  extended by jcontrol.system.Memory

public class Memory
extends Object

Get informations about memory consumption.


Method Summary
static int available()
          Get the immediately allocatable (available) size of memory.
static int free()
          Get the size of free memory.
static int size()
          Get the size of total memory.
static int sizeOf(Class cls)
          Get the size of used heap for the overgiven class of object.
static int sizeOf(Object obj)
          Get the size of used heap for the overgiven object.
static int used()
          Get the size of used memory.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, notifyAll, toString, wait
 

Method Detail

size

public static int size()
Get the size of total memory.

Returns:
total memory size in bytes

free

public static int free()
Get the size of free memory.

Returns:
free memory in bytes
See Also:
available()

used

public static int used()
Get the size of used memory. The returned value is equal the calculation of size() - free().

Returns:
used memory in bytes

available

public static int available()
Get the immediately allocatable (available) size of memory. While the garbage collector is removing unused objects (and classes on 16bit version this vm) - the heap is fragmented for a short time until the heap is compacted. In this time the size of free and allocatable (available) memory differs in it's return value.

Returns:
immediately allocatable memory in bytes

sizeOf

public static int sizeOf(Object obj)
Get the size of used heap for the overgiven object. Only runtime informations are stored onto heap. Example: sizeof(new byte[100]) returns a value of 100 + some bytes object-overhead

Parameters:
obj -
Returns:
size of used heap in bytes

sizeOf

public static int sizeOf(Class cls)
Get the size of used heap for the overgiven class of object. Only runtime informations are stored onto heap. Example: sizeof(new Object().getClass()) returns a value between 8 - n bytes of runtime informations

Parameters:
cls -
Returns:
size of used heap in bytes