Avoiding or handling OutOfMemoryError
929890Aug 26 2012 — edited Aug 27 2012I have to parse an XML document X which contains elements which are references to other XML documents. The documents (both, the X document and the XML documents referenced within X) are stored in an Oracle database (column xml of type XMLType) whereby the document name is the value of the id column.
When I load the X document, the references within X shall be resolved which means that the referenced XML documents shall be loaded and "merged" in the X document (replacing the referencing string (which is infact the document name)).
I already have a solution for this problem with relatively small document using XMLStreamReader/XMLStreamWriter in a recursive way. My problem is that I get an OutOfMemoryError when using a particular XML document which contains a lot of references (as well as the referenced documents).
What would be a good (and fast) strategy to avoid this problem? Is it a good idea to resolve the references up to a specified (configurable?) level and storing the result into a temporary table so that the so far (in heap memory) stored objects can be deleted. Then loading the temporarily stored MXL document... parsing and resolving the references of THAT temporary document... and so on.
Thank you. (It's really important to me!!!)
Edited by: 926887 on 27.08.2012 00:17