java accepts -Xmx1k happily as an argument, but "experiments show" this is still really something like an 8MB heap.
Googling didn't turn up anything to use, so I'm wondering, what is the smallest heap size you can mandate in Java?
Thanks, Eric
Edit:
It seems to vary a bit by platform and java version. On my Mac, with 1.6.0_24, the smallest I can configure it without error is:
$ java -Xms1k -Xmx4097k -XX:NewSize=192k -cp . Foo
5636096
or about 5.375M, where Foo.java is just:
public class Foo {
public static void main(String[] args) {
System.out.println(Runtime.getRuntime().totalMemory());
}
}
My environment is thus:
$ uname -a
Darwin turbo.local 10.7.0 Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386 i386
$ java -version
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)
As I mentioned in a comment below, I was setting a small heap trying to verify that an expensive algorithm really was using almost no memory, not trying to save money.
Thanks for the answers -- I was despondent at how little useful came up when I tried to google this.
From the docs at http://download.oracle.com/javase/6/docs/technotes/tools/windows/java.html
-Xmxn: This value must a multiple of 1024 greater than 2MB
And my quick test shows that:
java -Xmx2M HelloWorld
works on 1.6.0_24
Unless you are working on an extremely limited mobile device (in which case you should do your testing on that device) even 8MB isn't much
A server costs about $70/GB or about 50 cents per 8 MB.
Running with options -mx1m -XX:NewSize=256k
The following
System.out.println(Runtime.getRuntime().totalMemory()/1024);
Prints
2304
which is 2.25 MB.
Don't forget, the heap is not the entire application. You have permgen and share libraries to include in the total size.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With