[armedbear-cvs] r12019 - trunk/abcl/src/org/armedbear/lisp
Erik Huelsmann
ehuelsmann at common-lisp.net
Sat Jun 20 18:38:47 UTC 2009
Author: ehuelsmann
Date: Sat Jun 20 14:38:43 2009
New Revision: 12019
Log:
Don't GC before returning the free amount;
it clobbers the programmers' view on the state of memory.
At the same time extend the information made available
to the programmer; return free and maximum amounts too.
This is possible because the return value of ROOM is
implementation dependant.
Modified:
trunk/abcl/src/org/armedbear/lisp/room.java
Modified: trunk/abcl/src/org/armedbear/lisp/room.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/room.java (original)
+++ trunk/abcl/src/org/armedbear/lisp/room.java Sat Jun 20 14:38:43 2009
@@ -47,26 +47,9 @@
if (args.length > 1)
return error(new WrongNumberOfArgumentsException(this));
Runtime runtime = Runtime.getRuntime();
- long total = 0;
- long free = 0;
- long maxFree = 0;
- while (true) {
- try {
- runtime.gc();
- Thread.sleep(100);
- runtime.runFinalization();
- Thread.sleep(100);
- runtime.gc();
- Thread.sleep(100);
- }
- catch (InterruptedException e) {}
- total = runtime.totalMemory();
- free = runtime.freeMemory();
- if (free > maxFree)
- maxFree = free;
- else
- break;
- }
+ long total = runtime.totalMemory();
+ long free = runtime.freeMemory();
+
long used = total - free;
Stream out = getStandardOutput();
StringBuffer sb = new StringBuffer("Total memory ");
@@ -81,7 +64,8 @@
sb.append(System.getProperty("line.separator"));
out._writeString(sb.toString());
out._finishOutput();
- return number(used);
+ return LispThread.currentThread().setValues(number(used),
+ number(total),number(runtime.maxMemory()));
}
private static final Primitive ROOM = new room();
More information about the armedbear-cvs
mailing list