473,666 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XmlDataDocument \DataSet Memory Footprint, Feedback appreciated.

I am reading in xml files that equate to sql tables, via XmlDataDocument ,
and then operating on the DataSet. With the most simple app that just loads
the xml doc, I see the memory footprint of the app grow to roughly 5x the
size of the xml document after the xml doc is read. Can anyone comment on
this? Is this expected?

Below are two samples, the first hits northwind, and creates a 19meg
(roughly, on my machine) xml file. The second simply reads it in, with a
pause after reading so you can inspect the memory usage in task manager.

Any suggestions as to how I can get the footprint down much closer to the
size of the xml file would be greatly appreciated.

Thanks in advance!!

Derrick


Creation of sample xml file:
using System;
using System.Data;
using System.Data.Sql Client;
using System.Xml;
namespace DataExtract
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
string forXml = " FOR XML AUTO, XMLDATA";
SqlConnection mySqlConnection = new
SqlConnection(" server=127.0.0. 1;database=nort hwind;uid=sa;pw d=admin");
XmlTextReader myXmlReader = null;
SqlCommand mySqlCmd = new SqlCommand();
DataSet myDataSet = new DataSet();
mySqlConnection .Open();
mySqlCmd.Connec tion = mySqlConnection ;
mySqlCmd.Comman dText = "select * from orders cross join customers" + forXml;
myXmlReader = (XmlTextReader) mySqlCmd.Execut eXmlReader();
myDataSet.ReadX ml(myXmlReader, XmlReadMode.Fra gment);
myXmlReader.Clo se();
myDataSet.Write Xml("c:\\lotsa_ data.xml");
myDataSet.Write XmlSchema("c:\\ lotsa_data.xsd" );
myDataSet.Dispo se();
mySqlConnection .Close();
}
}
}

The reader:

using System.Data;
using System.Xml;
using System.IO;
namespace DataRead
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
Stream xsdStream = new StreamReader("c :\\lotsa_data.x sd").BaseStream ;
Stream xmlStream = new StreamReader("c :\\lotsa_data.x ml").BaseStream ;
XmlDataDocument myXmlDoc = new XmlDataDocument ();
myXmlDoc.DataSe t.ReadXmlSchema (xsdStream);
myXmlDoc.Load(x mlStream);
Console.WriteLi ne("Loaded...") ;
Console.ReadLin e();
}
}
}
Nov 15 '05 #1
3 2163
Hello

I suggest you use a memory profiler to track where your memory is consumed.
Here is a good one
http://www.scitech.se/memprofiler/
This software tells you the datatypes of allocated objects

Best regards
Sherif

"Derrick" <de*********@ex cite.com> wrote in message
news:Oo******** *****@tk2msftng p13.phx.gbl...
I am reading in xml files that equate to sql tables, via XmlDataDocument ,
and then operating on the DataSet. With the most simple app that just loads the xml doc, I see the memory footprint of the app grow to roughly 5x the
size of the xml document after the xml doc is read. Can anyone comment on
this? Is this expected?

Below are two samples, the first hits northwind, and creates a 19meg
(roughly, on my machine) xml file. The second simply reads it in, with a
pause after reading so you can inspect the memory usage in task manager.

Any suggestions as to how I can get the footprint down much closer to the
size of the xml file would be greatly appreciated.

Thanks in advance!!

Derrick


Creation of sample xml file:
using System;
using System.Data;
using System.Data.Sql Client;
using System.Xml;
namespace DataExtract
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
string forXml = " FOR XML AUTO, XMLDATA";
SqlConnection mySqlConnection = new
SqlConnection(" server=127.0.0. 1;database=nort hwind;uid=sa;pw d=admin");
XmlTextReader myXmlReader = null;
SqlCommand mySqlCmd = new SqlCommand();
DataSet myDataSet = new DataSet();
mySqlConnection .Open();
mySqlCmd.Connec tion = mySqlConnection ;
mySqlCmd.Comman dText = "select * from orders cross join customers" + forXml; myXmlReader = (XmlTextReader) mySqlCmd.Execut eXmlReader();
myDataSet.ReadX ml(myXmlReader, XmlReadMode.Fra gment);
myXmlReader.Clo se();
myDataSet.Write Xml("c:\\lotsa_ data.xml");
myDataSet.Write XmlSchema("c:\\ lotsa_data.xsd" );
myDataSet.Dispo se();
mySqlConnection .Close();
}
}
}

The reader:

using System.Data;
using System.Xml;
using System.IO;
namespace DataRead
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
Stream xsdStream = new StreamReader("c :\\lotsa_data.x sd").BaseStream ;
Stream xmlStream = new StreamReader("c :\\lotsa_data.x ml").BaseStream ;
XmlDataDocument myXmlDoc = new XmlDataDocument ();
myXmlDoc.DataSe t.ReadXmlSchema (xsdStream);
myXmlDoc.Load(x mlStream);
Console.WriteLi ne("Loaded...") ;
Console.ReadLin e();
}
}
}

Nov 15 '05 #2
Thanks, downloaded and tried it out, it basically looks like XML objects
(elements and attributes) are half the bag, strings the other half. Is
there a way to read in the XML as simple data, toss the xml associated
objects out, and end up with just native types in the DataSet tables?

The code that reads the xml file into a dataset is all core C#...

Thanks again!
"Sherif ElMetainy" <el************ *@wayout.net.NO SPAM> wrote in message
news:%2******** *********@TK2MS FTNGP11.phx.gbl ...
Hello

I suggest you use a memory profiler to track where your memory is consumed. Here is a good one
http://www.scitech.se/memprofiler/
This software tells you the datatypes of allocated objects

Best regards
Sherif

"Derrick" <de*********@ex cite.com> wrote in message
news:Oo******** *****@tk2msftng p13.phx.gbl...
I am reading in xml files that equate to sql tables, via XmlDataDocument , and then operating on the DataSet. With the most simple app that just

loads
the xml doc, I see the memory footprint of the app grow to roughly 5x the size of the xml document after the xml doc is read. Can anyone comment on this? Is this expected?

Below are two samples, the first hits northwind, and creates a 19meg
(roughly, on my machine) xml file. The second simply reads it in, with a pause after reading so you can inspect the memory usage in task manager.

Any suggestions as to how I can get the footprint down much closer to the size of the xml file would be greatly appreciated.

Thanks in advance!!

Derrick


Creation of sample xml file:
using System;
using System.Data;
using System.Data.Sql Client;
using System.Xml;
namespace DataExtract
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
string forXml = " FOR XML AUTO, XMLDATA";
SqlConnection mySqlConnection = new
SqlConnection(" server=127.0.0. 1;database=nort hwind;uid=sa;pw d=admin");
XmlTextReader myXmlReader = null;
SqlCommand mySqlCmd = new SqlCommand();
DataSet myDataSet = new DataSet();
mySqlConnection .Open();
mySqlCmd.Connec tion = mySqlConnection ;
mySqlCmd.Comman dText = "select * from orders cross join customers" +

forXml;
myXmlReader = (XmlTextReader) mySqlCmd.Execut eXmlReader();
myDataSet.ReadX ml(myXmlReader, XmlReadMode.Fra gment);
myXmlReader.Clo se();
myDataSet.Write Xml("c:\\lotsa_ data.xml");
myDataSet.Write XmlSchema("c:\\ lotsa_data.xsd" );
myDataSet.Dispo se();
mySqlConnection .Close();
}
}
}

The reader:

using System.Data;
using System.Xml;
using System.IO;
namespace DataRead
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
Stream xsdStream = new StreamReader("c :\\lotsa_data.x sd").BaseStream ;
Stream xmlStream = new StreamReader("c :\\lotsa_data.x ml").BaseStream ;
XmlDataDocument myXmlDoc = new XmlDataDocument ();
myXmlDoc.DataSe t.ReadXmlSchema (xsdStream);
myXmlDoc.Load(x mlStream);
Console.WriteLi ne("Loaded...") ;
Console.ReadLin e();
}
}
}


Nov 15 '05 #3
Hello

You can set the references to all xml objects to null, so that they are not
referenced anymore by your code.
Then they will be collected in the next garbage collection.

You can also force garbage collection to run immediately by calling
System.GC.Colle ct(), but many people thinks its better that you let the CLR
do garbage collection when it wants.

Best regards,
Sherif

"Derrick" <de*********@ex cite.com> wrote in message
news:eD******** ******@tk2msftn gp13.phx.gbl...
Thanks, downloaded and tried it out, it basically looks like XML objects
(elements and attributes) are half the bag, strings the other half. Is
there a way to read in the XML as simple data, toss the xml associated
objects out, and end up with just native types in the DataSet tables?

The code that reads the xml file into a dataset is all core C#...

Thanks again!
"Sherif ElMetainy" <el************ *@wayout.net.NO SPAM> wrote in message
news:%2******** *********@TK2MS FTNGP11.phx.gbl ...
Hello

I suggest you use a memory profiler to track where your memory is consumed.
Here is a good one
http://www.scitech.se/memprofiler/
This software tells you the datatypes of allocated objects

Best regards
Sherif

"Derrick" <de*********@ex cite.com> wrote in message
news:Oo******** *****@tk2msftng p13.phx.gbl...
I am reading in xml files that equate to sql tables, via XmlDataDocument , and then operating on the DataSet. With the most simple app that just

loads
the xml doc, I see the memory footprint of the app grow to roughly 5x the size of the xml document after the xml doc is read. Can anyone comment on
this? Is this expected?

Below are two samples, the first hits northwind, and creates a 19meg
(roughly, on my machine) xml file. The second simply reads it in,
with
a pause after reading so you can inspect the memory usage in task
manager.
Any suggestions as to how I can get the footprint down much closer to

the size of the xml file would be greatly appreciated.

Thanks in advance!!

Derrick


Creation of sample xml file:
using System;
using System.Data;
using System.Data.Sql Client;
using System.Xml;
namespace DataExtract
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
string forXml = " FOR XML AUTO, XMLDATA";
SqlConnection mySqlConnection = new
SqlConnection(" server=127.0.0. 1;database=nort hwind;uid=sa;pw d=admin");
XmlTextReader myXmlReader = null;
SqlCommand mySqlCmd = new SqlCommand();
DataSet myDataSet = new DataSet();
mySqlConnection .Open();
mySqlCmd.Connec tion = mySqlConnection ;
mySqlCmd.Comman dText = "select * from orders cross join customers" +

forXml;
myXmlReader = (XmlTextReader) mySqlCmd.Execut eXmlReader();
myDataSet.ReadX ml(myXmlReader, XmlReadMode.Fra gment);
myXmlReader.Clo se();
myDataSet.Write Xml("c:\\lotsa_ data.xml");
myDataSet.Write XmlSchema("c:\\ lotsa_data.xsd" );
myDataSet.Dispo se();
mySqlConnection .Close();
}
}
}

The reader:

using System.Data;
using System.Xml;
using System.IO;
namespace DataRead
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
Stream xsdStream = new StreamReader("c :\\lotsa_data.x sd").BaseStream ;
Stream xmlStream = new StreamReader("c :\\lotsa_data.x ml").BaseStream ;
XmlDataDocument myXmlDoc = new XmlDataDocument ();
myXmlDoc.DataSe t.ReadXmlSchema (xsdStream);
myXmlDoc.Load(x mlStream);
Console.WriteLi ne("Loaded...") ;
Console.ReadLin e();
}
}
}



Nov 15 '05 #4

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

Similar topics

2
3334
by: Mike Peretz | last post by:
I am trying to optimize my C# program, but no matter what I try the application keeps eating memory. I verified all the references and even got special software to count references. I made sure all the reference count reaches zero for all the objects that are no longer used. I also call Dispose as much as possible. Regardless, the memory is not freed. Even if I force the GC, some memory gets freed but not much.
2
460
by: tomvr | last post by:
Hello I have noticed some 'weird' memory usage in a vb.net windows app The situation is as follows I have an app (heavy on images) with 2 forms (actually there are more forms and on starting the app I load some things into memory for global use of the app but I'll use only 2 starting forms to explain the situation) situation 1 start app with form 1 (72mb memory usage), show form 2 and hide form 1 (89 mb memory usage
6
3272
by: Tom | last post by:
We have a VERY simple .NET C# Form Application, that has about a 23MB Memory Footprint. It starts a window runs a process and does a regular expression. I have done a GC.Collect to make sure that, no memory is lying around. GC reports only 84k of allocations. Starting 5-10 of this apps is going to start taking a considerable amount of memory. Is there a way to reduce this? Tom
2
2949
by: assi | last post by:
Hello all We are developing a large dotnet application, which includes ~ 120 assemblies. (total size of all binaries is ~ 20MB). Our application also references the following dotnet assemblies: System,System.XML, System.Windows.Forms, System.Drawing, System.Data, System.Design. We use dotnet framework 1.1 During initialization, the application scans a directory and loads the assemblies (using Assembly.LoadFrom). It then scans all...
9
2341
by: Mike P | last post by:
I know everything about reference counting and making sure you don't have large objects lying around. I have also profiled my app with multiple tools. I know about the fact GC collects memory but not necessary give it back to the OS. It seems that .NET win app will only return memory to the OS when the OS is asking for it. But!!! When the OS is asking for it is usually too late, tons of swapping and slow performance.
1
2022
by: Derrick | last post by:
Thanks to many on this newsgroup, I now have a prototype Windows Forms C# app that reads xml documents into DataSets via XmlDataDocument, and does *stuff* with it. I basically have about 25 megs worth of xml data that I read in and operate on. Once loaded, before doing anything of substance with the data, my app's memory footprint goes up to nearly 140 megs right off the bat. Question is, if this is not an expected observation, what...
1
416
by: Derrick | last post by:
I am reading in xml files that equate to sql tables, via XmlDataDocument, and then operating on the DataSet. With the most simple app that just loads the xml doc, I see the memory footprint of the app grow to roughly 5x the size of the xml document after the xml doc is read. Can anyone comment on this? Is this expected? Below are two samples, the first hits northwind, and creates a 19meg (roughly, on my machine) xml file. The second...
12
5044
by: Varun Kacholia | last post by:
Apologies if this has been answered somewhere, but Google did not produce any concrete results. I would like to find out the memory footprint of a vector<T>. I tried to dig in the STL code and if I understand correctly, its 3 * void(*) + sizeof(T) * size_of_vector. (3 ptrs for __M_start, __M_finish and __M_end_of_storage). If any STL guru could confirm my findings, that would be much appreciated.
9
4205
by: jeungster | last post by:
Hello, I'm trying to track down a memory issue with a C++ application that I'm working on: In a nutshell, the resident memory usage of my program continues to grow as the program runs. It starts off at a nice 4% of memory, then slowly grows up to 50% and beyond. This translates to around 2 gigs of physical memory, and that's really way more memory than this program should be taking up.
0
8445
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
8356
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
8871
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
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7386
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
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
5664
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
4198
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...
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.