hellzone
hellzone

Reputation: 5246

How to set maximum xmx and xms values without outofmemory exception

I am trying to run some .jar file but I am getting below error. The system has 20 gb of ram and my Xms and Xmx values are -Xms2048m -Xmx4096m

Are these values are too big or there is another thing causing this error?

java.lang.OutOfMemoryError: Java heap space

EDIT:

java -jar -Xms2048m -Xmx4096m /Filereadertest.jar

I am using java 1.7.51

Java HotSpot(TM) 64-Bit Server VM

Upvotes: 1

Views: 7594

Answers (2)

Amber Beriwal
Amber Beriwal

Reputation: 1598

Along with JRE version and architecture, heap space per process also depends upon the operating system in use.

For example, Windows 32-bit allows maximum 2 GB memory per process, which also includes size for stacks, libraries and other stuff. So in practice, we generally get 1.25 GB memory.

Have a look at: Oracle's Guidelines for Heap Space Sizing

Upvotes: 0

Peter Lawrey
Peter Lawrey

Reputation: 533880

Are these values are too big or there is another thing causing this error?

The default for the server JVM is 1/4 of main memory or 5 GB, so you are actually decreasing the maximum by setting this.

You could set it to 80% of main memory such as -Xmx16G

Upvotes: 2

Related Questions