2

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

Masih
  • 920
  • 2
  • 19
  • 36
  • 1
    An `OutOfMemoryError` might appear when when your physical system is low on memory. You allow the JVM to take up to 16Gib, but does your physical machine actually have that much memory _available_? – Matt Clark Sep 12 '18 at 15:38
  • Yes, it is a local server with 64G of RAM. – Masih Sep 12 '18 at 15:50
  • 1
    But what else is running? If you `cat /proc/meminfo`, you have enough `MemAvailable`? – Matt Clark Sep 12 '18 at 15:56
  • 1
    You can use something like `jconsole` to track what's happening with the heap. Out of curiosity what is your code doing when the exception occurs? Do you have a stack? Jconsole docs: https://docs.oracle.com/javase/10/management/using-jconsole.htm#JSMGM-GUID-258E47A7-78AC-4B73-B4E1-E06E4DD4FDDC – Taylor Sep 12 '18 at 15:59
  • 1
    MemTotal: 131947892 kB _ MemFree: 81041836 kB_ MemAvailable: 109647548 kB – Masih Sep 12 '18 at 16:00

1 Answers1

1
Topaco
  • 40,594
  • 4
  • 35
  • 62
  • Thanks. I didn't know that you have to set memory size once for the java and once for the program independently.I can see that haploview is using more than 9Gb of memory more than what you expected. But it seems to be working completely fine now. – Masih Sep 14 '18 at 14:13