When loading large XML document, OutOfMemory error happens. How do I deal with it?

DOM XML parser supports two modes: normal and delay load. In normal mode, the XML document is parsed and an XML DOM tree (node-tree) is created, after loading the source stream/file is not needed anymore as all data is stored in memory. In the delay load mode the XML document is parsed in the same way, but it is possible to specify what data type (comment, text, CDATA) not to store in the memory, the component will store its offset and size, and on each request to such node the data will be loaded and parsed from the source stream and then unloaded, so the source stream/file should not be closed until the XML document is freed/disposed.

The main usage of the delay load mode is to load XML documents with large data fields.

Sample usage:

XMLDocument. <a href="https://www.eldos.com/documentation/sbb/documentation/ref_cl_xmldomdocument_mtd_loadfromstream.html">LoadFromStream</a> (SourceStream, true, LoadNoData);

Where: LoadNoData is empty set of TElXMLDelayLoadMode type

Ready to get started?

Learn more about SecureBlackbox or download a free trial.

Download Now