title: Why does the (Oracle) JVM have a fixed upper limit for memory usage (-Xmx)?
body: <p>In the spirit of question <a href="https://stackoverflow.com/questions/3356005/java-why-does-maxpermsize-exist">Java: Why does MaxPermSize exist?</a>, I'd like to ask why the Oracle JVM uses a fixed upper limit for the size of its memory allocation pool.</p>
  <p>The default is 1/4 of your physical RAM (with upper &amp; lower limit); as a consequence, if you have a memory-hungry application you have to manually change the limit (parameter -Xmx), or your app will perform poorly, possible even crash with an OutOfMemoryError.</p>
  <p>Why does this fixed limit even exist? Why does the JVM not allocate memory as needed, like native programs do on most operating systems?</p>
  <p>This would solve a whole class of common problems with Java software (just Google to see how many hints there are on the net on solving problems by setting -Xmx).</p>
  <p><em>Edit:</em></p>
  <p>Some answers point out that this will protect the rest of the system from a Java program with a run-away memory leak; without the limit this would bring the whole system down by exhausting all memory. This is true. However, it is equally true for any other program, and modern OSes already let you limit the maximum memory for a programm (Linux ulimit, Windows &quot;Job Objects&quot;). So this does not really answer the question, which is &quot;Why does the JVM do it differently from most other programs / runtime environments?&quot;.</p>