I assumed that when a document was handled by the saxon:stream pseudo-function that the called document was available for garbage collection since the expectation is that the document is only read once.

However, I was fiddling with streaming in one of my scripts and I saw behavior that does comport to the above assumption.

In the stylesheet I use the following command:

<xsl:variable name="session.traces" select="saxon:stream(doc(session.extractor/@file)/student/session/systemTrace)"/>
(This command is used inside a loop that executes hundreds of times. In each call of the loop, a different file is referenced by "session.extractor/@file". These files are about 3M in size.)

This caused the application to run out of memory.

I added

<xsl:value-of select="saxon:discard-document(document(session.extractor/@file))/a"/>

and this fixed the memory issue.

Is this the expected behavior?



"A false conclusion, once arrived at and widely accepted is not dislodged easily, and the less it is understood, the more tenaciously it is held." - Cantor's Law of Preservation of Ignorance.