Changeset 12019


Ignore:
Timestamp:
06/20/09 18:38:43 (14 years ago)
Author:
ehuelsmann
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/room.java

    r11488 r12019  
    4848            return error(new WrongNumberOfArgumentsException(this));
    4949        Runtime runtime = Runtime.getRuntime();
    50         long total = 0;
    51         long free = 0;
    52         long maxFree = 0;
    53         while (true) {
    54             try {
    55                 runtime.gc();
    56                 Thread.sleep(100);
    57                 runtime.runFinalization();
    58                 Thread.sleep(100);
    59                 runtime.gc();
    60                 Thread.sleep(100);
    61             }
    62             catch (InterruptedException e) {}
    63             total = runtime.totalMemory();
    64             free = runtime.freeMemory();
    65             if (free > maxFree)
    66                 maxFree = free;
    67             else
    68                 break;
    69         }
     50        long total = runtime.totalMemory();
     51        long free = runtime.freeMemory();
     52
    7053        long used = total - free;
    7154        Stream out = getStandardOutput();
     
    8265        out._writeString(sb.toString());
    8366        out._finishOutput();
    84         return number(used);
     67        return LispThread.currentThread().setValues(number(used),
     68                number(total),number(runtime.maxMemory()));
    8569    }
    8670
Note: See TracChangeset for help on using the changeset viewer.