English 中文(简体)
产生巨大的XML的记忆错误
原标题:Out of memory error while creating huge XML

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

问题回答

你们可以说:

java -Xmx512m ...

java -Xmx1024m ...

或whatever size you need.

请注意,您可能需要修订算法,以便把XML直接编为输出Stream,而不是首先建立庞大的记忆结构,然后将<><>>的XML编为输出Stream。 (这全部取决于该法典正在做什么细节)。)

I had a similar case earlier this year where I was generating XML into a StringBuffer and then writing the StringBuffer into an HTTP response OutputStream. This worked fine until someone asked f或200Mb of XML! I quickly altered the code to generate the XML directly to the OutputStream, saving not only the memory, but CPU.

如果你需要整理大型的XML文档(并增加 Java粒并不总能发挥作用),那么,你需要一个能够使XML流落起来的SRP教区,而不是把整个DOM树装成记忆。

你们是否使用大范围插座?

attach视你们的记忆。

你们在管理你的时候,是否增加了有关 Java的证书选择? 例如:

java -Xmx1024m ...

a. 给它一个蒸气空间。

如果这属于申请服务器或网络集装箱内,则通常会发现这种选择被埋在“汇辑”档案或开户口中。

页: 1

帮助

通常,你将XML文件写到一个流子,在这种情况下,你不必把全部xml的剂量记在记忆中,因为你可以把文件写到你建造的溪流。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签