Search code examples
javaout-of-memoryheap-size

Setting heap size in Java


I am trying to run a Java tool in Linux Ubuntu system and I keep getting the following error after the program imports 12% of the data:

Fata Error:
Exception in thread 'Thread-l" java.lang.OutOfMemoryError: java heap space

I tried to set the heap size using

java -Xms8G -Xmx16G -jar Haploview.jar

but the error appears again exactly at same point after just using less than 500M Of the allocated Ram. Using the command 'free -m' I can see that there are lots of free RAM memory left but I don't know why Java do not use it


Solution