int before = Options.getCurrentHeapSize(); boolean heapGrew = Options.updateCurrentHeapSize((int) Plan.reservedMemory()); if (heapGrew) { if (Plan.verbose >= 2) { VM.sysWrite("Heap grew from ", (int) (before / 1024)); VM.sysWrite("KB to ", (int) (Options.getCurrentHeapSize() / 1024)); VM.sysWriteln("KB");
double usage = Plan.reservedMemory() / ((double) Plan.totalMemory()); if (usage > OUT_OF_MEMORY_THRESHOLD) { if (why == INTERNALLY_TRIGGERED) { if (Plan.verbose >= 2) { VM.sysWriteln("Throwing OutOfMemoryError: usage = ", usage); VM.sysWriteln("                           reserved (kb) = ", (int) (Plan.reservedMemory() / 1024)); VM.sysWriteln("                           total    (Kb) = ", (int) (Plan.totalMemory() / 1024)); } throw (new OutOfMemoryError());
  public static final void triggerCollection(int why)    throws VM_PragmaInterruptible {    if (VM.VerifyAssertions) VM._assert((why >= 0) && (why < TRIGGER_REASONS));     // VM_Scheduler.dumpStack();    if ((Plan.verbose == 1 || Plan.verbose == 2) 	&& (why == EXTERNALLY_TRIGGERED_GC)) {      VM.sysWrite("[Forced GC]");    }    if (Plan.verbose > 2) VM.sysWriteln("Collection triggered due to ", triggerReasons[why]);    long start = System.currentTimeMillis();    VM_CollectorThread.collect(VM_CollectorThread.handshake);    if (Plan.verbose > 2) VM.sysWriteln("Collection finished (ms): ", 					(int) (System.currentTimeMillis() - start));    if (Plan.isLastGCFull()) {      int before = Options.getCurrentHeapSize();      boolean heapGrew = Options.updateCurrentHeapSize((int) Plan.reservedMemory());      if (heapGrew) {	if (Plan.verbose >= 2) {	  VM.sysWrite("Heap grew from ", (int) (before / 1024));	  VM.sysWrite("KB to ", (int) (Options.getCurrentHeapSize() / 1024));	  VM.sysWriteln("KB");	}      }      else {	double usage = Plan.reservedMemory() / ((double) Plan.totalMemory());	if (usage > OUT_OF_MEMORY_THRESHOLD) {	  if (why == INTERNALLY_TRIGGERED) {	    if (Plan.verbose >= 2) {	      VM.sysWriteln("Throwing OutOfMemoryError: usage = ", usage);	      VM.sysWriteln("                           reserved (kb) = ", (int) (Plan.reservedMemory() / 1024));	      VM.sysWriteln("                           total    (Kb) = ", (int) (Plan.totalMemory() / 1024));	    }	    throw (new OutOfMemoryError());	  }	  ReferenceProcessor.setClearSoftReferences(true); // clear all possible reference objects	  triggerCollection(INTERNALLY_TRIGGERED);	}      }    } // if (Plan.isLastFullGC())  }