473,834 Members | 1,491 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Long duration of call XmlDataDocument .CloneNode

Hi,

why the duration of call the CloneNode(true) is steadily increasing? First
call is 0.004s and 100th is 0.16s! XML file is 5kB only, no disk swap.

XmlDataDocument xml = new XmlDataDocument ();
xml.Load(@"C:\f oo.xml");
for(int i = 0; i < 100; i++)
{
XmlNode node = xml.CloneNode(t rue);
}

Whole code for youre test (copy+paste):

using System.Xml;
using System.Runtime. InteropServices ;

class Class1
{
[DllImport("kern el32.dll")]
internal extern static short QueryPerformanc eCounter(ref
long lpPerformanceCo unt);
[DllImport("kern el32.dll")]
internal extern static short QueryPerformanc eFrequency(ref
long lpFrequency);

public static void CloneNodeStress Test()
{
long start = 0;
long stop = 0;
long frequency = long.MaxValue;

QueryPerformanc eFrequency(ref frequency);

XmlDataDocument xml = new XmlDataDocument ();
xml.Load(@"C:\f oo.xml");

for(int i = 0; i < 100; i++)
{
QueryPerformanc eCounter(ref start);

XmlNode node = xml.CloneNode(t rue);

QueryPerformanc eCounter(ref stop);

double elapsed = (stop - start) / (double)frequen cy;
Console.WriteLi ne(i + "=" + elapsed);
start = 0;
stop = 0;
}
}

[STAThread]
static void Main(string[] args)
{
CloneNodeStress Test();
}
}

Thank's, Petr Felzmann.
Nov 12 '05 #1
1 1265
My guess is that each iteration of the loop eats a bit more memory.
Remember that the framework does garbage collection, so not all 'lost'
references are freed right away. Also, it may be doing garbage
collection while your loop is executing, which would take some time
from your program as well.

Finally, you're calling out to unmanaged code, and breaking the barrier
between managed and unmanaged code has a significant peformance hit and
maybe the GC has to do some clean up there too, or perhaps there is a
memory leak in the unmanged code.

One thing you could do is instead of using the PerfCounters, just use
two DateTime's, and subtract them. If you still find the same
behavior, its probably due to the garbage collection.

Andy

Nov 12 '05 #2

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

Similar topics

1
2128
by: MonkeyBoy | last post by:
I am doing some some HTML manipulation in client-side script (IE5.x and IE6.x browsers only). Something like.. var tmpHTML = oTable.outerHTML // do something to the HTML her oTable.outerHTML = tmpHTML Before the changes, client-side .Net field validators (RegularExpressionValidator, RangeValidator, etc.) work fine... after the changes, the modified HTML works correctly but the validators stop functioning. Seems that the onchange handler...
1
3536
by: Peter Feakins | last post by:
We're building some web services that are primarily being consumed by a .net application. We're returning datasets for that purpose. We're also have to provide access to these services to classic asp pages. To do this we're returning a XmlDataDocument ie Public Function GetDataAsXml(...) return new XmlDataDocument(GetDataAsDataSet) End Function
0
1320
by: Raj | last post by:
hi, I associate dataset with one xmldatadocument? how can I disassociate from xmldatadocument, so I can associate with another xmldatadocument. and, how can I remove xmldatadocument from memory? I am new to xml. any suggetions would be highly appretiated.
0
2157
by: gilly3 | last post by:
Reposting to a more relevant group. I am passing a generic dataset into a new XMLDataDocument and then parsing the XML with XSLT. The idea being that I can parse any dataset with the same xslt, and dynamically generate an html table. The problem is when the DataSet contains a null value, the node for that record is not created. Then when the xml parses it, there are too few cells in some of the table rows. I can think of a couple...
2
3906
by: James Ankrom | last post by:
Why does this fail? Dim relResources As New Data.DataRelation("Application_Resources", ..Tables("User_Applications").Columns("Application_id"), ..Tables("Resource_Rights").Columns("Application_id"), False) mUserData.Relations.Add(relResources) relResources.Nested = True Dim UserDataXML As System.Xml.XmlDataDocument = New System.Xml.XmlDataDocument(mUserData)
4
2509
by: Kevin Schultz | last post by:
Hello all. I am interfacing my computer to the outside world for an experiment and we would like to know how much time the calling function takes. The specs say this should happen on the order of a microsecond, which is faster than we need. We would like to call 30 or so of these functions in 0.5 milliseconds and before committing to purchasing this interface system, we would like to make sure it fits our needs. However, we are having...
0
1431
by: Steve | last post by:
I have a dataset. I fill it with two recordsets from SQL queries. Tables are called tblPlanFYSpendingStage, tblSpendingStage.
4
8279
by: Adrian Meyer | last post by:
Hi, On the server I code the following web service: ))] public XmlDataDocument GetTypedXmlDataDocument() { sqlDataAdapter1.Fill(typedDataSet1); XmlDataDocument dataDoc
1
1033
by: mrleokarthik | last post by:
Csharp. Framework.2 iam converting word document's into pdf, which involves com dll. 1. iam looping all documents 2. open a word document and save it as pdf 3. during the step 2 most of the documents get converted successfully but some documents takes long time to convert or even shows some user messages. if it happens i want to terminate the document and continue with next document, since it is automation process with no user...
0
9796
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9643
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10790
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10214
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7755
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6952
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5624
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3079
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.