edu.stanford.nlp.util
Class MemoryMonitor.PeakMemoryMonitor

java.lang.Object
  extended by edu.stanford.nlp.util.MemoryMonitor.PeakMemoryMonitor
All Implemented Interfaces:
Runnable
Enclosing class:
MemoryMonitor

public static class MemoryMonitor.PeakMemoryMonitor
extends Object
implements Runnable

This class offers a simple way to track the peak memory used by a program. Simply launch a PeakMemoryMonitor as

Thread monitor = new Thread(new PeakMemoryMonitor());
monitor.start()
and then when you want to stop monitoring, call
monitor.interrupt(); monitor.join();
You only need the last line if you want to be sure the monitor stops before you move on in the code; and strictly speaking, you should surround the monitor.join() call with a try/catch block, as the Thread you are running could itself be interrupted, so you should actually have something like
monitor.interrupt(); try { monitor.join(); } catch (InterruptedException ex) { // handle the exception }
or else throw the exception.

Author:
ilya

Constructor Summary
MemoryMonitor.PeakMemoryMonitor()
           
MemoryMonitor.PeakMemoryMonitor(int pollFrequency, int logFrequency)
           
MemoryMonitor.PeakMemoryMonitor(int pollFrequency, int logFrequency, PrintStream out)
           
 
Method Summary
 void log()
           
 void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryMonitor.PeakMemoryMonitor

public MemoryMonitor.PeakMemoryMonitor()

MemoryMonitor.PeakMemoryMonitor

public MemoryMonitor.PeakMemoryMonitor(int pollFrequency,
                                       int logFrequency)
Parameters:
pollFrequency - frequency, in milliseconds, with which to poll
logFrequency - frequency, in milliseconds, with which to log maximum memory used so far

MemoryMonitor.PeakMemoryMonitor

public MemoryMonitor.PeakMemoryMonitor(int pollFrequency,
                                       int logFrequency,
                                       PrintStream out)
Method Detail

run

public void run()
Specified by:
run in interface Runnable

log

public void log()


Stanford NLP Group