What is the smallest you can make a (Oracle JVM) java heap?
<p>java accepts -Xmx1k happily as an argument, but "experiments show" this is still really something like an 8MB heap.</p>

<p>Googling didn't turn up anything to use, so I'm wondering, what is the smallest heap size you can mandate in Java?</p>

<p>Thanks,
Eric</p>

<p>Edit:</p>

<p>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:</p>

<pre><code>$ java -Xms1k -Xmx4097k -XX:NewSize=192k  -cp . Foo
5636096
</code></pre>

<p>or about 5.375M, where Foo.java is just:</p>

<pre><code>public class Foo {
    public static void main(String[] args) {
        System.out.println(Runtime.getRuntime().totalMemory());
    }
}
</code></pre>

<p>My environment is thus:</p>

<pre><code>$ 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)
</code></pre>

<p>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.</p>

<p>Thanks for the answers -- I was despondent at how little useful came up when I tried to google this.</p>
