public class MemoryWatchDog
extends java.lang.Object
public void myMethod() {
try {
MemoryWatchDog.checkAvailableMemory()
...
} catch (Exception e)
System.out.println(e.getMessage());
}
}
Modifier and Type | Class and Description |
---|---|
static class |
MemoryWatchDog.ExpectedMemoryCapacityException
This exception class is thrown when the memory is about to exceed its capacity.
|
Modifier and Type | Field and Description |
---|---|
static double |
MAXIMUM_PROPORTION_USED
The maximum proportion of the memory that can be used before throwing an
ExpectedMemoryCapacityException.
|
static double |
MINIMUM_FREE_SPACE
The minimum memory space that should be free to allow the system to work properly.
|
Constructor and Description |
---|
MemoryWatchDog() |
Modifier and Type | Method and Description |
---|---|
static double |
checkAvailableMemory()
Checks if the available memory is still above the threshold is used.
|
static double |
checkUsedMemory()
Checks the memory that is currently used.
|
public static double MAXIMUM_PROPORTION_USED
public static double MINIMUM_FREE_SPACE
public static double checkAvailableMemory() throws MemoryWatchDog.ExpectedMemoryCapacityException
a
- ExpectedMemoryCapacityException objectMemoryWatchDog.ExpectedMemoryCapacityException
public static double checkUsedMemory()