TUM CCSM Commons

edu.tum.cs.commons.system
Class MemoryMonitor

java.lang.Object
  extended by edu.tum.cs.commons.system.MemoryMonitor

public class MemoryMonitor
extends java.lang.Object

A simple class for monitoring memory usage of an application. A second thread is started which periodically polls the memory status.

Note: Due to performance reasons the method getMaximumMemoryUsage() and reset() are not synchronized, so calling these methods while the memory monitor is still running might lead to undesired results. Therefore it is recommended stop the memory befor calling getMaximumMemoryUsage() or reset().

Version:
$Revision: 26268 $
Author:
Florian Deissenboeck, $Author: juergens $
Rating:
GREEN Hash: 5CEE7382009C9846609F2FA2C23D122D

Constructor Summary
MemoryMonitor()
          Construct a new MemoryMonitor with the default monitoring interval.
MemoryMonitor(int period)
          Construct a new MemoryMonitor.
 
Method Summary
 long getMaximumMemoryUsage()
          Obtain maximum amount of memory used since the monitor was started or reset.Use this method only when monitor is stopped.
 void reset()
          Reset the maximum memory usage value.
 void start()
          Start the memory monitor.
 void stop()
          Stop the memory monitor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryMonitor

public MemoryMonitor()
Construct a new MemoryMonitor with the default monitoring interval.


MemoryMonitor

public MemoryMonitor(int period)
Construct a new MemoryMonitor.

Parameters:
period - time between subsequent polls to obtain memory status
See Also:
start()
Method Detail

start

public void start()
Start the memory monitor.

See Also:
stop()

stop

public void stop()
Stop the memory monitor. Memory monitor can be restarted safely after stopping without loosing the current maximum value.

See Also:
start(), reset()

reset

public void reset()
Reset the maximum memory usage value. Use this method only when monitor is stopped.

See Also:
stop()

getMaximumMemoryUsage

public long getMaximumMemoryUsage()
Obtain maximum amount of memory used since the monitor was started or reset.Use this method only when monitor is stopped.

Returns:
maximum memory usage [byte]
See Also:
stop()

TUM CCSM Commons

TUM CCSM Commons - 2.7