Re: '[xslt] "document() function memory usage"'

Since no one else is responding to your question, I'll try.  Take my
comments "with a grain of salt", since most of what I say is from
reading the library sources, and I have been known to get badly
confused ;-).

When you use the document() function, the library has no way of
knowing whether you will use it again, or whether this is a
transient access.  Any time you work with a document, it has to be
parsed, etc., which is relatively time-consuming.  In order to avoid
the overhead of re-reading and re-parsing a document multiple times,
the library maintains a "document list" as a part of the
"transformation context".  The parsed image of any document which is
accessed is added to this list, and the list (together with the
documents it references) is only freed when the transformation
context is freed.

Using xsltproc, I can't think of any easy way around your problem.



Kasimier Buchcik said:
> Hi,
> on 3/24/2004 5:56 PM Kasimier Buchcik wrote:
>> Hi,
>> I'm trying to transform the W3C DOM-Test-Suite to Delphi. Doing
>> this I
>> have a stylesheet that loads about 520 XML files (2-4 KB) in a
>> loop and
>> processes them. Since the transformation eats all the memory on my
>> test
>> machine (256 MB real memory, 630 MB virtual memory), the question
>> arises
>> if the documents loaded by the following construct will be
>> released on
>> transformation end only:
>> <xsl:for-each select="*[local-name() = 'suite.member']">
>>    <xsl:apply-templates select="document(@href)" />
>> </xsl:for-each>
>> (Note: the output method "text" is used; the transformation runs
>> smoothly if only a few tests are processed)
>> If they are released at transformation end only, could there be
>> any way
>> of implementing destruction of no more used documents, if
>> xsl:apply-templates has been processed?
>> Do some other explanations come to mind why this transformation
>> uses so
>> much memory?
> Since there was no feedback on the issue, I assume some information
> was
> missing - I'll try once more.
> The question is: is a document, imported with the function
> "document()",
> freed after the application of <xsl:apply-templates> in the example
> above, or is it freed when the whole transformation has ended?
> I'm asking this, since I tried to process many sub-documents with
> document() and my machine ran out of memory. IOW, it feels like the
> sub-document are cumulated in memory.
> I'm running on a w2k machine and used xsltproc for the test:
> L:\Open_idom\XPtest\w3c>xsltproc --version
> Using libxml 20607, libxslt 10104 and libexslt 804
> xsltproc was compiled against libxml 20607, libxslt 10104 and
> libexslt 804
> libxslt 10104 was compiled against libxml 20607
> libexslt 804 was compiled against libxml 20607
> Regards,
> Kasimier

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]