com.bea.jvm
Interface MemorySystem

All Superinterfaces:
Describable, JVMComponent

public interface MemorySystem
extends JVMComponent

Interface to the JVM memory system.

Author:
Calle Wilund, Marcus Hirt

Method Summary
 GarbageCollector getGarbageCollector()
          Returns the GarbageCollector subsystem.
 long getMaxHeapSize()
          Returns the maximum size the heap may grow to, in bytes.
 long getTotalHeapSize()
          Returns the size of the heap that the JVM has allocated, in bytes.
 long getUsedHeapSize()
          Returns the committed heap size of the JVM in bytes.
 boolean isExitOnOutOfMemory()
          Returns true if the JVM will exit with an error code instead of throwing an OutOfMemoryError, false if it throws an OutOfMemoryError.
 boolean isHeapSizeLocked()
          This method returns false if the heap size is controlled by the JVM, false otherwise.
 void setExitOnOutOfMemory(boolean exit)
          This method will change whether the JVM will exit with an error code, instead of throwing an OutOfMemoryError.
 void setHeapSizeLocked(boolean lock)
          This method changes the JVM's ability to adaptively change the heap size.
 void suggestHeapSize(long heapSize)
          This method will suggest the heapsize to be used.
 
Methods inherited from interface com.bea.jvm.Describable
getDescription
 

Method Detail

getMaxHeapSize

public long getMaxHeapSize()
                    throws NotAvailableException
Returns the maximum size the heap may grow to, in bytes. This is normally the same as the size specified with the -mx flag.

Returns:
the maximum heap size of the JVM (-mx) in bytes or the longest value of type long if -mx is not set.
Throws:
NotAvailableException - if this functionality isn't available in this JVM.

getTotalHeapSize

public long getTotalHeapSize()
                      throws NotAvailableException
Returns the size of the heap that the JVM has allocated, in bytes.

Returns:
the allocated heap size of the JVM in bytes.
Throws:
NotAvailableException - if this functionality isn't available in this JVM.

getUsedHeapSize

public long getUsedHeapSize()
                     throws NotAvailableException
Returns the committed heap size of the JVM in bytes.

Returns:
the committed heap size of JVM in bytes.
Throws:
NotAvailableException - if this functionality isn't available in this JVM.

getGarbageCollector

public GarbageCollector getGarbageCollector()
                                     throws NotAvailableException
Returns the GarbageCollector subsystem.

Returns:
the GarbageCollector subsystem.
Throws:
NotAvailableException - if this functionality isn't available in this JVM.
See Also:
GarbageCollector

suggestHeapSize

public void suggestHeapSize(long heapSize)
                     throws NotAvailableException
This method will suggest the heapsize to be used. The method may trigg a full GC if needed for changing the heap size. The actual obtained heap size may differ from the suggested heap size for a number of reasons, for instance address alignment, not enough available memory, the suggested size is too small to fit the currently used heap or larger than the specified maximum heap size etc.

Parameters:
heapSize - the wanted heap size.
Throws:
NotAvailableException - if not supported by the VM.

setHeapSizeLocked

public void setHeapSizeLocked(boolean lock)
                       throws NotAvailableException
This method changes the JVM's ability to adaptively change the heap size. The heap size can be changed manually using the suggestHeapSize(long heapSize) method even if the heap size has been locked.

Parameters:
lock - if true, the heap size will no longer be changed by the JVM, if false, the JVM is in control over the heap size.
Throws:
NotAvailableException - if not supported by the VM.

isHeapSizeLocked

public boolean isHeapSizeLocked()
                         throws NotAvailableException
This method returns false if the heap size is controlled by the JVM, false otherwise.

Returns:
false if the heap size is controlled by the JVM, true if it has been frozen to its current value.
Throws:
NotAvailableException - if not supported by the VM.

setExitOnOutOfMemory

public void setExitOnOutOfMemory(boolean exit)
                          throws NotAvailableException
This method will change whether the JVM will exit with an error code, instead of throwing an OutOfMemoryError. (@see OutOfMemoryError)

In the case of JRockit, the exit code will be 72.

Parameters:
exit - if true, the JVM will exit when out of memory, if false, it will throw an OutOfMemoryError.
Throws:
NotAvailableException - if not supported by the VM.

isExitOnOutOfMemory

public boolean isExitOnOutOfMemory()
                            throws NotAvailableException
Returns true if the JVM will exit with an error code instead of throwing an OutOfMemoryError, false if it throws an OutOfMemoryError. (@see OutOfMemoryError)

Default is false.

Returns:
true if the JVM will exit with an error code instead of throwing an OutOfMemoryError, false if it throws an OutOfMemoryError.
Throws:
NotAvailableException - if not supported by the VM.