About Memory Allocation
Sammy Chen <[email protected]> Fri, 27 Feb 2009 17:48:27 +0800
| Newsgroups | gmane.comp.java.vm.kaffe.general |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I got a memory allocation problem. I =A0wrote 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