1

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

5
  • What version of the VM are you running? Can you include the exact command you are trying to execute as well as the output from java -version? Commented Dec 31, 2015 at 15:43
  • Are you by chance running the 32-bit version of Java? Seeing the exact full output of java -version would tell us this. Commented Dec 31, 2015 at 15:51
  • @Todd no its 64 bit vm server. Commented Dec 31, 2015 at 16:01
  • OOM suggests that runtime ran out of memory, unless this JAR is allocating memory indefinitely, it just needs more memory. Keep adding to it, if you suspect that this JAR should not be using this much memory then you'll have to debug the root cause. Commented Dec 31, 2015 at 16:04
  • Did you analyse heap dumps using heap analyzer? If not I would suggest you to analyse heap dumps which would tell you which part of the code is causing OOM . Commented Dec 31, 2015 at 16:18

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.