public class MemoryCheck
extends java.lang.Object
To get a snapshot of current memory first call runGC()
and then call getUsedMemory()
.
Example code:
MemoryCheck.runGC();
Long currentMem = MemoryCheck.getUsedMemory();
Constructor and Description |
---|
MemoryCheck() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getDateStamp()
Return a string for the current time and date, sutiable for display in log files and output to standout:
|
static long |
getUsedMemory()
Gets the current amount of memory being used by this app, in bytes.
|
static java.lang.String |
getUsedMemoryInMegs()
Gets the current amount of memory being used by this app, in megabytes.
|
static void |
main(java.lang.String[] args)
The main program for the MemoryCheck class
|
static void |
runGC()
Runs object finization and the garbage collector several times.
|
public static void main(java.lang.String[] args) throws java.lang.Exception
args
- The command line argumentsjava.lang.Exception
- If errorpublic static long getUsedMemory()
runGC()
prior to calling this method.public static java.lang.String getUsedMemoryInMegs()
runGC()
prior to calling this method.public static void runGC()
public static java.lang.String getDateStamp()