[kaffe] About Memory Allocation

Sammy Chen seeme.goo at gmail.com
Fri Feb 27 01:48:36 PST 2009


Hi,

I got a memory allocation problem. I  wrote a simple java code and
tested its memory usage.
I found that kaffe vm allocated much larger memory than sun vm.

The code is listed as follows.

public class Hello {
    public static void main(String[] args) {

   System.out.println("1. Hello.java Used Memory: " +
           (Runtime.getRuntime().totalMemory() -
Runtime.getRuntime().freeMemory())+ " bytes");

   System.out.println("Hello World!");

   System.out.println("2. Hello.java Used Memory: " +
          (Runtime.getRuntime().totalMemory() -
Runtime.getRuntime().freeMemory())+ " bytes");

   }

}

The result executed on kaffe vm is
    Hello.java Used Memory: 2,518,214 bytes
    Hello World!
    Hello.java Used Memory: 3,169,202 bytes

But, if running on sun vm, the result is
    Hello.java Used Memory: 186,736 bytes
    Hello World!
    Hello.java Used Memory: 186,736 bytes

Could anyone tell me what the problem is? How can I reduce memory
usage on kaffe vm?

Many thanks,
Sammy




More information about the kaffe mailing list