ecologylab.appframework
Class Memory

java.lang.Object
  extended by ecologylab.appframework.Memory

public class Memory
extends java.lang.Object

Utility routines related to memory management, used to watch the JVM's consumption of memory, and to kick the garbage collector into action.


Field Summary
static int DANGER_THRESHOLD
          Less than this many bytes of memory free means danger, baby.
static int gcCount
          Number of times we've called gc().
static boolean isMicroshaftVM
           
 
Constructor Summary
Memory()
           
 
Method Summary
static long getFreeMemoryInBytes()
           
static java.lang.String getFreeMemoryInK()
           
static java.lang.String K(long numBytes)
           
static boolean outOfMemory(java.lang.Throwable throwable)
           
static void reclaim()
          Prod the garbage collector, and print a message about memory status.
static void reclaim(java.lang.String s)
          Prod the garbage collector, and print a message about memory status.
static boolean reclaimIfLow()
          Try to reclaim memory if it seems to be in low supply.
static void reclaimQuiet()
           
static void recover(java.lang.Throwable throwable, java.lang.String msg)
           
static java.lang.String threads()
           
static java.lang.String usage()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DANGER_THRESHOLD

public static final int DANGER_THRESHOLD
Less than this many bytes of memory free means danger, baby. Currently set at 32M.

See Also:
Constant Field Values

gcCount

public static int gcCount
Number of times we've called gc().


isMicroshaftVM

public static boolean isMicroshaftVM
Constructor Detail

Memory

public Memory()
Method Detail

reclaim

public static void reclaim()
Prod the garbage collector, and print a message about memory status.


reclaim

public static void reclaim(java.lang.String s)
Prod the garbage collector, and print a message about memory status.

Parameters:
s - Part of the message to be printed, to identify call site.

reclaimQuiet

public static void reclaimQuiet()

reclaimIfLow

public static boolean reclaimIfLow()
Try to reclaim memory if it seems to be in low supply.

Returns:
true if memory status is in danger and more agressive measures are called for.

recover

public static void recover(java.lang.Throwable throwable,
                           java.lang.String msg)

usage

public static java.lang.String usage()

K

public static java.lang.String K(long numBytes)

threads

public static java.lang.String threads()

outOfMemory

public static boolean outOfMemory(java.lang.Throwable throwable)
Returns:
true if its time to give up!

getFreeMemoryInBytes

public static long getFreeMemoryInBytes()

getFreeMemoryInK

public static java.lang.String getFreeMemoryInK()