473,395 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

XslTransform and Long Long String in memory

Hi,

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).

Problem:

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
succeeded
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
Statistics:
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 ========

<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 />
</xml>

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

<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:a="uri:aaa"
version="1.0"

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

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

<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>

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

</xsl:transform>

====== 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();
transform.Load(args[1]);
XPathDocument source = new XPathDocument(args[0]);
XmlTextWriter writer = new XmlTextWriter(args[2], Encoding.UTF8);
XsltArgumentList xslArgs = new XsltArgumentList();
transform.Transform(source, xslArgs, writer);
writer.Close();

}
}
}


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

Yuriy
Nov 12 '05 #2

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

Similar topics

0
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...
2
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...
3
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...
1
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...
4
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...
4
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#...
3
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...
12
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)...
9
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.