SecureBlackbox 16: Resolving OutOfMemory Errors when loading large XML documents

Note: This article applies only to SecureBlackbox Legacy. For future development please consider using the latest version.

The 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, etc.) not to store in memory. The component will store its offset and size, and on each request to such a 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

The following code shows the usage of the delay load mode, where LoadNoData is an empty set of the TElXMLDelayLoadMode type

XMLDocument.LoadFromStream (SourceStream, true, LoadNoData);

We appreciate your feedback.  If you have any questions, comments, or suggestions about this article please contact our support team at kb@nsoftware.com.