public class GetMem extends Object
Note: this class is likely to be used in contexts where we don't
have logging set up, so System.err
and System.out
are used.
Constructor and Description |
---|
GetMem() |
Modifier and Type | Method and Description |
---|---|
private <T> T |
callMXBeanMethod(String methodName,
T defaultValue)
Call a method belonging to
OperatingSystemMXBean and return
the result. |
static String |
getMemory()
Get total system memory and print it out--accounts for 32bit JRE
limitation of 1.5GB.
|
static void |
main(String[] args)
The main.
|
public GetMem()
private <T> T callMXBeanMethod(String methodName, T defaultValue)
OperatingSystemMXBean
and return
the result.T
- Type of the expected return and defaultValue
.methodName
- Name of OperatingSystemMXBean
method to call.
Cannot be null
or empty.defaultValue
- Value returned if methodName
call fails.methodName
call, or
defaultValue
.public static String getMemory()
String
representation of the total amount of system
memory.