User_G
User_G

Reputation: 13

What should be the JVM heap size (Xms Xmx) for JDK8 64-bit on Linux having physical memory of 16 GB RAM and 8 CPU

I have 16GB of RAM and 8 CPU's on my Linux server with JDK8 x64 installed.

I have set up JVM heap size as below but keep getting java.lang.OutOfMemoryError

JAVA_OPTS="-Xms2048m -Xmx4096m -XX:MaxPermSize=1024m -XX:-UseGCOverheadLimit

Any suggestions, what should be the minimum/maximum/PermGen heap size.

Upvotes: 0

Views: 2439

Answers (1)

Gautam Jain
Gautam Jain

Reputation: 33

Out of memory error is caused, because the heap size consumed by your code is more than what is allocated by Java.

This could be because of multiple reasons.

1) Your code is bulky and needs more memory: A simple code to just print "Hello World" won't consume much memory. However, a lengthy and bulky application of 1 GB source code would consume huge memory. If that is case, you can try to increase your memory arguments.

2) Bad Code: Bad code, which consumes useless memory, and does not release it later, causes more heap size to be used continously than the garbage collected. If that is the code you might need to identify the issue with your code. You can actually identify the method or class that is consuming this huge amount of heap, using Java Flight Record (JFR).

Ideal Heap Memory Size varies from from case to case and your requirements must be known for exact heap size.

Upvotes: 3

Related Questions