Skip to content
Advertisement

JVM error when try to allocate more than 128M Xms, without specifying Xmx

I am seeing an JVM issue when I am running my application and I simply to below java commands:

JavaScript

Even Xms is set to 128M does not work:

JavaScript

Works only when Xms is set to 64M or less:

JavaScript

The interesting thing is if I specify Xmx, then it works well.

JavaScript

More interesting thing is: All above commands run well on another machine with same OS (Windows Server 2008 R2 Enterprise SP1) & same jdk version. Physical Memory is 16GB.

Any idea?

Advertisement

Answer

Any idea?

Well the obvious conclusion is that if you want to use -Xms to specify the initial heap size, and you want to set the size to a value that is larger than the default maximum heap size, you need to specify a maximum heap size.

The reason that you are getting different results on different machines is that the JVM computes the default heap size in different ways, depending on the version of Java and on the execution platform. In some cases it is a constant. In others, it depends on the amount of physical memory on the system.

Just set the maximum heap size explicitly and you won’t have this problem.


If you want to find out what the default heap size is for a given machine, run this command:

JavaScript
Advertisement