Nirvana Scheduling : Memory Triggers Example

scheduler myMemory {
/*
 Declare the MemoryManager task/trigger. Not really required to do
*/
declare MemoryManager mem;

/*
 Just using the MemoryManager task / trigger and not the declared mem as an example.
*/
 when (MemoryManager.freeMemory <10000000){
 MemoryManager.flush(false);
 }

/*
 Now when the Free Memory on the realm drops below 1000000 bytes force the
 realm to release ALL available memory
*/
 when ( mem.freeMemory <1000000){
 mem.flush(true);
 }

/*
 This is the same as the one above, except not using the declared name.
*/
 when ( MemoryManager.freeMemory <1000000){
 MemoryManager.flush(true);
 }

/*
 totalMemory available on the realm
*/
 when ( MemoryManager.totalMemory <20000000 ){
 Logger.report("Declared Memory too small for realm");
 }

/*
 Out Of Memory counter, increments whenever the realm handles an out of memory exception
*/
 when ( MemoryManager.outOfMemory> 2){
 Logger.report("Realm has run out of memory more then the threshold allowed");
 }

}