472,808 Members | 2,777 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,808 software developers and data experts.

XslTransform and Long Long String in memory


Can anybody explain the following?

Say I have the following source XML and XSLT (see below). No matter what
this XSLT does. It is just a sample to show a problem. the idea is that
XSLT transforms small XML into quite big XML. Now, I have a straightforward
C# (see below) code that does this transform and writes result into XmlTextWriter.
(Oleg's NXSLT.EXE is also suitable).


If source XML is bigger, say several MBs (please don't explain me that it
is not good to use XSLT for such documents), the sample transform should
produce a very big (add more calls to template b if necessary and <a /> elements
to source document) XML. While result is writtent to the writer I expect
that it will not consume much more memory that source document. (I even
tried to provide custom XmlWriter which runs GC each 1000 element outputed).
However, I get OutOfMemory exception.

So, I looked at heap and what I see. I have in memory one 0.5GB object.
It is System.String containing:

uri:aaauri:aaauri:aaauri:aaauri:aaauri:aaauri:aaau ri:aaauri:aaauri:aaauri:aaauri:aaa................ ...(much
longer - 0.5 GB)

Samples below generate smaller string, but anyway it is many times concantenated
namespaces declared in XSLT (except XSLT namespace).

This XSLT runs fine in MSXML4 producing output to SAXHandler interface.
Any ideas how to avoid this long string in memory?

Parts of memory dump:

=== DUMP ===
..load sos

!DumpHeap -type System.String
PDB symbol for mscorwks.dll not loaded
Loaded Son of Strike data table version 5 from "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\msco rwks.dll"
Address MT Size
00af117c 79c125c8 28
00af11f0 79c125c8 108
00af125c 79c125c8 20
>>>>> I WILL DUMP THIS >>>>>00b3bf04 79c125c8 1044
00b3d524 79c125c8 76
00b3d570 79c125c8 76
00b3d5bc 79c125c8 84
total 1647 objects
MT Count TotalSize Class Name
79c125c8 1647 91732 System.String
Total 1647 objects

!DumpObj 00b3bf04
Name: System.String
MethodTable 0x79c125c8
EEClass 0x79c12914
Size 1044(0x414) bytes
mdToken: 0200000f (c:\windows\microsoft.net\framework\v1.1.4322\msco rlib.dll)
String: uri:aaauri:aaauri:aaauri:aaauri:aaauri:aaauri:aaau ri:aaauri:aaauri:aaauri:aaauri:aaauri:aaauri:aaaur i:aaauri:aaauri:aaauri:aaauri:aaauri:aaauri:aaauri :aaauri:aaauri:aaauri:aaauri:aaauri:aaauri:aaauri: aaauri:aaauri:aaauri:aaauri:aaauri:aaauri:aaauri:a aauri:aaauri:aaauri:aaauri:aaauri:aaa
FieldDesc*: 79c12978
MT Field Offset Type Attr Value Name
79c125c8 4000013 4 System.Int32 instance 513 m_arrayLength
79c125c8 4000014 8 System.Int32 instance 287 m_stringLength
79c125c8 4000015 c System.Char instance 75 m_firstChar
79c125c8 4000016 0 CLASS shared static Empty Domain:Value 00148f98:00af125c << 79c125c8 4000017 4 CLASS shared static WhitespaceChars Domain:Value 00148f98:00af1270 <<

======== XML ========

<a /> <a /> <a /> <a /> <a /> <a /> <a /> <a /> <a /> <a />
<a /> <a /> <a /> <a /> <a /> <a /> <a /> <a /> <a /> <a />
<a /> <a /> <a /> <a /> <a /> <a /> <a /> <a /> <a /> <a />
<a /> <a /> <a /> <a /> <a /> <a /> <a /> <a /> <a /> <a />

======== XSLT ========


<xsl:output method="xml" encoding="utf-8" />

<xsl:template name="b">
<c />

<xsl:template match="a">
<xsl:call-template name="b" />
<xsl:call-template name="b" />
<xsl:call-template name="b" />
<xsl:call-template name="b" />

<xsl:template match="/xml">
<xsl:apply-templates />


====== C# ===============

namespace some {

using System;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;

class App {

[STAThread] static void Main(string[] args) {
XslTransform transform = new XslTransform();
XPathDocument source = new XPathDocument(args[0]);
XmlTextWriter writer = new XmlTextWriter(args[2], Encoding.UTF8);
XsltArgumentList xslArgs = new XsltArgumentList();
transform.Transform(source, xslArgs, writer);


Nov 12 '05 #1
1 1643
Does anybody try to repproduce it?

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Kevin Conroy | last post by:
I'm making a 6-tiered application that is using Xml to tie the various layers together in a very clean manner. I'm also trying to do this on the 1.1 Framework although I'm willing to switch to the...
by: Graham Pengelly | last post by:
Hi I am trying to transform on System.Xml.XmlDocument into another using XslTransform without writing the object out to a file. I am guessing it should work something like this... public...
by: Steve | last post by:
Is there any way of specifying the startMode when using the xslTransform class? We are updating code which used msxml to the system.xml classes but can find no way to specify the startMode. We...
by: manlio | last post by:
how can I load a XSL string (not an xsl file!!) with XslTransform ??? If I use the code: // Create a new XslTransform class and load the stylesheet XslTransform myXslTransform = new...
by: Sean Hoffman | last post by:
Framework 1.1 SP1. Page.xml is about 1.5mg. m_oXSLTransform.Transform takes about 2 minutes. When Page.xml is trimmed down to a smaller doc, it takes about 2 seconds. Same code ran in about...
by: David S. Alexander | last post by:
I am trying to transform XML to XML using an XSLT in C#, but the root node of my XML is not being matched by the XSLT if it has an xmlns attribute. Am I handling my namespaces incorrectly? My C#...
by: arochax | last post by:
Hi. I'm using XslTransform to transform a XML resulting of a Dataset into a Excel spreadsheet. But the object is not releasing its resources while transforming and I'm getting OutOfMemory...
by: InvalidLastName | last post by:
We have been used XslTransform. .NET 1.1, for transform XML document, Dataset with xsl to HTML. Some of these html contents contain javascript and links. For example: // javascript if (a &gt; b)...
by: WT | last post by:
Hello, I have code created with .net 1.0 and migrated to 3.5. Form 2.0 the XslTransform class is obsolete and the vs2008 compiler generates warnings that these classes are absolete suggesting to...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: lllomh | last post by:
How does React native implement an English player?
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.