Monday 15 February 2010

java - Out of memory error while creating huge XML -


Because of the Java heap space on java.lang.AbstractStringBuilder.expandCapacity (unknown source) Java: java.lang. OutOfMemoryError .lang.AbstractStringBuilder.append on java.io.StringWriter.write (unknown source) java.lang.StringBuffer.append (unknown source) at com.ctc.wstx.sw.BufferingXmlWriter.flushBuffer (unknown source) (BufferingXmlWriter. java: 1358) com.ctc.wstx.sw.BufferingXmlWriter.flush (BufferingXmlWriter.java:224) com.ctc.wstx.sw. com.ctc.wstx.sw.BufferingXmlWriter.close (on BufferingXmlWriter.java:198) On BaseStreamWriter._finishDocument com.ctc.wstx.sw.BaseStreamWriter.close (BaseStreamWriter.java:264) to (BaseStreamWriter.java:1429) on org.codehaus.stax2.ri.Stax2EventWriterImpl.close (Stax2EventWriterImpl.java:178) organization .utils.JcoFunctionToXmlTransformer.transform (JcoFunctionToXmlTransformer.java:163

the goal - to XML to convert back by SAP as the data JcoTable
problem - java.lang.OutOfMemoryError : Java Stack Space

When the data is too big, in such cases where the number of rows in excess of 25,000 is getting more than the error we are facing the same. Ksmel as nodes and to convert XML to read node stream and external custom code problems while (using Jaco API method to use) using stacks API

You can increase the memory limit of JMM by saying:

  java-xmx512m ... < / Code> 

or

  java-xmx1024m ...  

or whatever size you want

Note that you may need to modify your algorithm, for example to serialize XML directly into the output stream, first do not create a large memory structure and then from that to output the stream to serial (It all depends on the details of what the code is doing.)

I had a case similar to this year where I created XML in stringbuffer And was then Stringbfr was writing an HTTP response OutputStream. As long as no 200 MB asked for XML, it works fine! I soon changed the code to generate the XML to the outputstream, not only saved the memory, but the CPU


No comments:

Post a Comment