public class MemoryMonitor extends java.lang.Object
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()
.Constructor and Description |
---|
MemoryMonitor()
Construct a new
MemoryMonitor with the default monitoring
interval. |
MemoryMonitor(int period)
Construct a new
MemoryMonitor . |
Modifier and Type | Method and Description |
---|---|
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.
|
public MemoryMonitor()
MemoryMonitor
with the default monitoring
interval.public MemoryMonitor(int period)
MemoryMonitor
.period
- time between subsequent polls to obtain memory statusstart()
public void stop()
public void reset()
stop()
public long getMaximumMemoryUsage()
stop()