Memory management with XML Extensions

At execution time, XML Extensions allocates memory and caches stylesheets and other artifacts of the XML document handling process. This is a standard technique to enhance performance, trading reduced execution time for additional memory usage. However, it is possible for a long running program that processes a substantial number of different XML documents to cause enough additional memory allocation that performance degrades, typically due to virtual memory swapping. As an example, a program might sit in a loop, waiting for an XML document to arrive in a directory; see the example for XML FIND FILE.

The program may use the XML TERMINATE statement to cause all memory allocated by XML Extensions (with the exception of the document returned by the XML GET TEXT and XML IMPORT TEXT statements) for the run unit to be released. However, the XML INITIALIZE statement and any other XML Extensions statements that control optional behavior (for example, XML ENABLE ALL-OCCURRENCES) must be called to re-establish the XML environment before additional XML documents are processed.