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 , XML EXPORT TEXT and XML TRANSFORM 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.
Alternatively, you can use the XML FLUSH CACHE statement to flush cached documents, and the XML DISABLE CACHE statement to prevent caching of documents. These ways of managing memory usage are less sweeping than the XML TERMINATE statement.
The XML CLEAR XSL-PARAMETERS will free any memory used for parameter name/value pairs that have been set, and will not disturb caching or other memory usage. The XML FREE TEXT statement will free memory allocated by the XML EXPORT TEXT or the XML TRANSFORM TEXT statements.