public class MemoryMonitor extends Object
Modifier and Type | Class and Description |
---|---|
static class |
MemoryMonitor.PeakMemoryMonitor
This class offers a simple way to track the peak memory used by a program.
|
Modifier and Type | Field and Description |
---|---|
protected int |
freeMem |
protected long |
lastPoll |
static int |
MAX_SWAPS |
protected long |
pollEvery |
protected Runtime |
r |
protected int |
swaps |
protected int |
usedSwap |
Constructor and Description |
---|
MemoryMonitor() |
MemoryMonitor(long millis) |
Modifier and Type | Method and Description |
---|---|
int |
getMaxAvailableMemory() |
int |
getMaxAvailableMemory(boolean accurate) |
int |
getMaxMemory() |
int |
getSystemFreeMemory(boolean accurate) |
double |
getSystemSwapsPerSec() |
int |
getSystemUsedSwap() |
int |
getUsedMemory() |
int |
getUsedMemory(boolean accurate) |
static void |
main(String[] args) |
protected static ArrayList<String> |
parseFields(BufferedReader br,
String splitStr,
int[] lineNums,
int[] positions) |
void |
pollAtMostEvery(long millis) |
void |
pollFree(boolean force) |
void |
pollVMstat(boolean force) |
boolean |
systemIsSwapping() |
String |
toString() |
public static final int MAX_SWAPS
protected long lastPoll
protected long pollEvery
protected int freeMem
protected int usedSwap
protected int swaps
protected Runtime r
public MemoryMonitor()
public MemoryMonitor(long millis)
public void pollAtMostEvery(long millis)
public int getMaxMemory()
public int getMaxAvailableMemory()
public int getMaxAvailableMemory(boolean accurate)
public int getUsedMemory()
public int getUsedMemory(boolean accurate)
public int getSystemFreeMemory(boolean accurate)
public int getSystemUsedSwap()
public double getSystemSwapsPerSec()
protected static ArrayList<String> parseFields(BufferedReader br, String splitStr, int[] lineNums, int[] positions) throws IOException
IOException
public void pollFree(boolean force)
public void pollVMstat(boolean force)
public boolean systemIsSwapping()
public static void main(String[] args) throws InterruptedException
InterruptedException