I'm getting java.lang.OutOfMemoryError in one of my java application. I increased size of minimum and maximum heap size under "VM arguments" in eclipse:
-XX:+HeapDumpOnOutOfMemoryError -Xmx8g -Xms2g However, I'm still getting same error. In jconsole.exe it displays the following:
If I understood correctly, then I still have plenty of heap memory.
I also analyzed the memory dump using eclipse MAT
As you can see, it shows problem but only 9 MB. So what's exactly the problem? shouldn't I have enough free heap memory?
Not strictly relating to java but this can also be caused by trying to store something in your memory that can't fit all in one place.
Consider a car parking lot with metal bars between each parking space. There are 20 empty motorcycle spots. You want to park your SUV. Even though the total area of the available space is greater than your vehicles requirement you still can't park as it cant fit in any single spot.
I dont know if this is the case here, but this is the most common reason I run into this problem.
Are you trying to store something significantly larger than anything else anywhere near where this error happens?