0

I am getting java.lang.OutOfMemoryError: Java heap space Exception while trying Marshal large number of objects in to XML, however previously i was using less object or less size of xml file that time JAXB marshaller.marshal(message, fi); was absolutely fine. Now as per new requirement in my project we need to increase data that in XML file i have tweak the logic as per new story. However after tweaking logic i run the report its looks fine 2-3 times after that started throw OOM exception.

Note : i have increase Xms, Xmx and XX:MaxPermSize but still facing same issue.

Could you guys please help me to get resolve this issue.

hari
  • 144
  • 1
  • 2
  • 9
  • Can you check if the values of Xms, Xmx and XX:MaxPermSize are getting reflected. You can do that by invoking the jmap app in jdk bin folder as below: ./jmap -heap – Praveen Kumar Apr 04 '16 at 09:54
  • Hi Praveen, I tried same on linux but "Jmap coammand not found", i tried http://stackoverflow.com/questions/11237872/java-command-not-found-on-linux. – hari Apr 04 '16 at 11:33
  • cd locationOfJdkBin after that do ./jmap -heap processid – Praveen Kumar Apr 04 '16 at 11:59
  • Yes i can see Xms, Xmx and XX:MaxPermSize getting reflected, but i get it from "ps -ef|grep" command . We dont have access to java installation dir. Any ways parameter as below -XX:NewSize=512m -XX:MaxNewSize=1024m -XX:PermSize=512m -XX:MaxPermSize=512m -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC – hari Apr 04 '16 at 12:44
  • Can you find the Xmx value and increase it to a larger value to accommodate the increase in data handling of you app. That sould solve the problem – Praveen Kumar Apr 04 '16 at 16:40
  • are you using SAX parser ?? – Praveen Kumar Apr 05 '16 at 05:58
  • @praveen I am using JAXB. – hari Apr 05 '16 at 10:11

1 Answers1

0

The java.lang.OutOfMemoryError: Java heap space is commonly caused when the JVM runs out of heap space.

This can be mainly due to two reasons

1. Memory leak
2. excessive computation by the app

In your case i assume its the second one causing the problem. This can be solved by setting the Xmx value to a larger value than the current one.

If you are using tomcat you can do this in the setenv.sh inside tomcat bin. setting CATALINA_OPTS=Xmx1024M (or any other value)

Praveen Kumar
  • 1,515
  • 1
  • 21
  • 39
  • Hi Praveen, I am already using Xmx2048M, however still we are facing same issue. Any ways in case of marshaling we are getting 25 lakh lines in XML, i thought it may be reason of OOM. Can you suggest any thing else that can solve OOM in Jaxb Marshaling. – hari Apr 05 '16 at 05:16
  • @hari what is the max Xmx value that your application can have ? if there is a limitation then can you think of parsing the xml file in batches or some sort of caching strategy. – Praveen Kumar Apr 05 '16 at 05:48
  • this link should be helpful http://stackoverflow.com/questions/26310595/how-to-parse-big-50-gb-xml-files-in-java – Praveen Kumar Apr 05 '16 at 05:51
  • currently we have configured Xmx = 2048M. as per http://stackoverflow.com/questions/26310595/how-to-parse-big-50-gb-xml-files-in-java we are using JAXB and whole project implemented in same manner. Its tough to revert JAXB in SAX – hari Apr 05 '16 at 08:52