Caused by: java.lang.OutOfMemoryError: Java heap space at java.lang.AbstractStringBuilder.expandCapacity(Unknown Source) at java.lang.AbstractStringBuilder.append(Unknown Source) at java.lang.StringBuffer.append(Unknown Source) at java.io.StringWriter.write(Unknown Source) at com.ctc.wstx.sw.BufferingXmlWriter.flushBuffer(BufferingXmlWriter.java:1358) at com.ctc.wstx.sw.BufferingXmlWriter.flush(BufferingXmlWriter.java:224) at com.ctc.wstx.sw.BufferingXmlWriter.close(BufferingXmlWriter.java:198) at com.ctc.wstx.sw.BaseStreamWriter._finishDocument(BaseStreamWriter.java:1429) at com.ctc.wstx.sw.BaseStreamWriter.close(BaseStreamWriter.java:264) at org.codehaus.stax2.ri.Stax2EventWriterImpl.close(Stax2EventWriterImpl.java:178) at org.utils.JcoFunctionToXmlTransformer.transform(JcoFunctionToXmlTransformer.java:163
GOAL - To convert the data returned by SAP in form of JcoTable to XML.
PROBLEM - java.lang.OutOfMemoryError: Java heap space.
When the data is very huge, in cases where number of rows exceeds 25,000 getting the above error We are facing the same issue, even while using the Jco API method to convert to XML and also using the external custom code (using Stax API) to read node by node and stream as XML