Log.write("GC Message: Heap changed from "); Log.write(oldSize.toWord().rshl(LOG_BYTES_IN_KBYTE).toInt()); Log.write("KB to "); Log.write(newSize.toWord().rshl(LOG_BYTES_IN_KBYTE).toInt());
Log.write("GC Message: Heap changed from "); Log.writeDec(oldSize.toWord().rshl(LOG_BYTES_IN_KBYTE)); Log.write("KB to "); Log.writeDec(newSize.toWord().rshl(LOG_BYTES_IN_KBYTE));
  public static boolean considerHeapSize() {    Extent oldSize = currentHeapSize;    Extent reserved = Plan.reservedMemory();    double liveRatio = reserved.toLong() / ((double) currentHeapSize.toLong());    double ratio = computeHeapChangeRatio(liveRatio);    Extent newSize = Word.fromInt((int)(ratio * (double) (oldSize.toLong()>>LOG_BYTES_IN_MBYTE))).lsh(LOG_BYTES_IN_MBYTE).toExtent(); // do arith in MB to avoid overflow    if (newSize.LT(reserved)) newSize = reserved;    newSize = newSize.add(BYTES_IN_MBYTE - 1).toWord().rshl(LOG_BYTES_IN_MBYTE).lsh(LOG_BYTES_IN_MBYTE).toExtent(); // round to next megabyte    if (newSize.GT(maxHeapSize)) newSize = maxHeapSize;    if (newSize.NE(oldSize)) {      // Heap size is going to change      currentHeapSize = newSize;      if (BasePlan.verbose.getValue() >= 2) {         Log.write("GC Message: Heap changed from "); Log.write(oldSize.toWord().rshl(LOG_BYTES_IN_KBYTE).toInt());         Log.write("KB to "); Log.write(newSize.toWord().rshl(LOG_BYTES_IN_KBYTE).toInt());         Log.writeln("KB");       }       return true;    } else {      return false;    }  }