tags:

views:

97

answers:

2

Out of interest - Does a default exist or is it different on each OS?

If it does, what are the defaults? Incredibly hard to find!

+3  A: 

According to java documentation the default for the Sun/Oracle Windows and Solaris/Linux JVMs are 64MB. This could be different for different JVM vendors though. For example, the default -Xmx value for JRockit is the lesser of 75% of the total amount of memory or 1GB.

If you are curious about what maximum amount of memory you can use on your JVM, at runtime you can call:

System.out.println(Runtime.getRuntime().maxMemory());
krock
Hi krock. Unfortunately, it looks like the `man` page for `java` in version 1.5 was incorrect. The actual defaults are described in the "ergonomics" article I linked to in my answer.In Java 6.0, the `man` page was amended to simply say, "The default value is chosen at runtime based on system configuration. For more information, see HotSpot Ergonomics."
Matt Solnit
+3  A: 

You can find the details in the Java 5.0 Ergonomics documentation. Specifically:

  • For a "server class" machine (2+ processors, 2+ GB RAM), the default maximum heap size is ¼ of physical memory, up to 1Gbyte
  • For a "regular" machine, it's 64 MB.
Matt Solnit
Windows machines don't get an automatic "server" flag applied though. Presumably the assumption is that Windows machines will normally run client applications. I'm pretty sure that you have to explicitly set the memory size to what you need. Otherwise the default is 64MB
Fortyrunner
According to the linked docs, __32-bit__ Windows machines don't get an automatic "server" flag, but 64-bit machines do. Still, worth noting. Thanks :-).
Matt Solnit