weka.core
Class Memory

java.lang.Object
  extended by weka.core.Memory

public class Memory
extends java.lang.Object

A little helper class for Memory management. Very crude, since JDK 1.4 doesn't offer real Memory Management.

The memory management can be disabled by using the setEnabled(boolean) method.

Version:
$Revision: 1.1.2.4 $
Author:
FracPete (fracpete at waikato dot ac dot nz)
See Also:
setEnabled(boolean)

Constructor Summary
Memory()
          initializes the memory management without GUI support
Memory(boolean useGUI)
          initializes the memory management
 
Method Summary
 long getCurrent()
          returns the current memory consumption
 long getInitial()
          returns the initial size of the JVM
 long getMax()
          returns the maximum amount of memory that can be assigned
 boolean getUseGUI()
          whether to display a dialog in case of a problem (= TRUE) or just print on stderr (= FALSE)
 boolean isEnabled()
          returns whether the memory management is enabled
 boolean isOutOfMemory()
          checks if there's still enough memory left.
 void setEnabled(boolean value)
          sets whether the memory management is enabled
 void showOutOfMemory()
          prints an error message if OutOfMemory (and if GUI is present a dialog), otherwise nothing happens.
 void stopThreads()
          stops all the current threads, to make a restart possible
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Memory

public Memory()
initializes the memory management without GUI support


Memory

public Memory(boolean useGUI)
initializes the memory management

Parameters:
useGUI - whether a GUI is present
Method Detail

isEnabled

public boolean isEnabled()
returns whether the memory management is enabled


setEnabled

public void setEnabled(boolean value)
sets whether the memory management is enabled


getUseGUI

public boolean getUseGUI()
whether to display a dialog in case of a problem (= TRUE) or just print on stderr (= FALSE)


getInitial

public long getInitial()
returns the initial size of the JVM


getCurrent

public long getCurrent()
returns the current memory consumption


getMax

public long getMax()
returns the maximum amount of memory that can be assigned


isOutOfMemory

public boolean isOutOfMemory()
checks if there's still enough memory left. if ENABLED is true, then false is returned always


showOutOfMemory

public void showOutOfMemory()
prints an error message if OutOfMemory (and if GUI is present a dialog), otherwise nothing happens. isOutOfMemory() has to be called beforehand, since it sets all the memory parameters.

See Also:
isOutOfMemory(), #ENABLED

stopThreads

public void stopThreads()
stops all the current threads, to make a restart possible