de.hpi.fgis.dude.util
Class MemoryChecker

java.lang.Object
  extended by de.hpi.fgis.dude.util.MemoryChecker

public class MemoryChecker
extends Object

MemoryChecker is a Singleton implementation, that maintains the memory usage.

Author:
Matthias Pohl

Constructor Summary
protected MemoryChecker()
          Initializes the singleton instance.
 
Method Summary
 boolean enoughMemoryAvailable()
          Checks whether there is enough memory available.
static MemoryChecker getInstance()
          Singleton method for returning the Singleton instance.
 long getMaximumMemory()
          Returns the maximum amount of memory that can be used.
 double getMaximumMemoryUsage()
          Returns the maximum memory usage in percent.
static long getUsedVMMemory()
          Returns the amount of already used memory.
 void makeMemoryUsageSnapshot()
          Checks the memory usage status and makes a statistical snapshot.
 void setMaximumMemoryUsage(double maxUsage)
          Sets the maximum memory usage in percent.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MemoryChecker

protected MemoryChecker()
Initializes the singleton instance.

Method Detail

getInstance

public static MemoryChecker getInstance()
Singleton method for returning the Singleton instance.

Returns:
The MemoryChecker Singleton instance.

getUsedVMMemory

public static long getUsedVMMemory()
Returns the amount of already used memory.

Returns:
The amount of already used memory.

getMaximumMemory

public long getMaximumMemory()
Returns the maximum amount of memory that can be used.

Returns:
The absolute number of bytes that can be used.

setMaximumMemoryUsage

public void setMaximumMemoryUsage(double maxUsage)
Sets the maximum memory usage in percent.

Parameters:
maxUsage - The maximum usage.

getMaximumMemoryUsage

public double getMaximumMemoryUsage()
Returns the maximum memory usage in percent.

Returns:
The maximum memory usage in percent.

makeMemoryUsageSnapshot

public void makeMemoryUsageSnapshot()
Checks the memory usage status and makes a statistical snapshot. These statistics can be used to calculate the average memory usage.


enoughMemoryAvailable

public boolean enoughMemoryAvailable()
Checks whether there is enough memory available. This decision is made by using the statistics gathered by calling makeMemoryUsageSnapshot(). This method returns true , if the average memory usage value fits into memory; otherwise false.

Returns:
true, if enough memory is available; otherwise false.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011 Hasso Plattner Institute - Chair of Information Systems. All Rights Reserved.