Home All Groups Group Topic Archive Search About

Getting out of memory when DataSet.GetXml()

Author
2 Mar 2007 3:08 PM
OverTheTop
When the dataset is too large it thows OutOfMemory Exception although
that there is enough momory on the web server, is this a bug in .net
or something must be configured?! The Dataset contains near 50 000
rows. How can I escape this. Please help?

Author
2 Mar 2007 5:17 PM
Miha Markic [MVP C#]
..net handles memory a bit differently and might use more memory than the
size of dataset file when loading.
Did you try adding memory? How much memory do your server have and how large
is the xml file?

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/


Show quote
"OverTheTop" <vanko.georg***@gmail.com> wrote in message
news:1172848118.781548.201860@30g2000cwc.googlegroups.com...
> When the dataset is too large it thows OutOfMemory Exception although
> that there is enough momory on the web server, is this a bug in .net
> or something must be configured?! The Dataset contains near 50 000
> rows. How can I escape this. Please help?
>
Author
3 Mar 2007 11:47 AM
OverTheTop
Hi Miha

the web server has 1.5 GB free memory...but when the exception was
trown the memory on the server used was 150 MB...I don't know why the
server didn't use all his memory available...may be .net is playing
stupied...I don't know what is the size of the
dataset...sorry...Monday on work I'll check :)

Miha Markic [MVP C#] íàïèñà:
Show quote
> .net handles memory a bit differently and might use more memory than the
> size of dataset file when loading.
> Did you try adding memory? How much memory do your server have and how large
> is the xml file?
>
> --
> Miha Markic [MVP C#, INETA Country Leader for Slovenia]
> RightHand .NET consulting & development www.rthand.com
> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>
>
> "OverTheTop" <vanko.georg***@gmail.com> wrote in message
> news:1172848118.781548.201860@30g2000cwc.googlegroups.com...
> > When the dataset is too large it thows OutOfMemory Exception although
> > that there is enough momory on the web server, is this a bug in .net
> > or something must be configured?! The Dataset contains near 50 000
> > rows. How can I escape this. Please help?
> >
Author
3 Mar 2007 12:26 PM
Miha Markic [MVP C#]
Hm, that's odd.
The problem when you see much memory available and you get outofmemory
exception might be caused by memory fragmentation.
Or perhpas there is a bug somewhere, hard to tell.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"OverTheTop" <vanko.georg***@gmail.com> wrote in message
news:1172922426.724358.81810@t69g2000cwt.googlegroups.com...
Hi Miha

the web server has 1.5 GB free memory...but when the exception was
trown the memory on the server used was 150 MB...I don't know why the
server didn't use all his memory available...may be .net is playing
stupied...I don't know what is the size of the
dataset...sorry...Monday on work I'll check :)

Miha Markic [MVP C#] íàïèñà:
Show quote
> .net handles memory a bit differently and might use more memory than the
> size of dataset file when loading.
> Did you try adding memory? How much memory do your server have and how
> large
> is the xml file?
>
> --
> Miha Markic [MVP C#, INETA Country Leader for Slovenia]
> RightHand .NET consulting & development www.rthand.com
> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>
>
> "OverTheTop" <vanko.georg***@gmail.com> wrote in message
> news:1172848118.781548.201860@30g2000cwc.googlegroups.com...
> > When the dataset is too large it thows OutOfMemory Exception although
> > that there is enough momory on the web server, is this a bug in .net
> > or something must be configured?! The Dataset contains near 50 000
> > rows. How can I escape this. Please help?
> >
Author
3 Mar 2007 12:35 AM
Rad [Visual C# MVP]
On 2 Mar 2007 07:08:38 -0800, OverTheTop wrote:

> When the dataset is too large it thows OutOfMemory Exception although
> that there is enough momory on the web server, is this a bug in .net
> or something must be configured?! The Dataset contains near 50 000
> rows. How can I escape this. Please help?

Well ... for starters I would try to see if I can get the size of the
dataset down. Is it possible to load less data?

Author
3 Mar 2007 11:49 AM
OverTheTop
Hi Rad

Because of the application there is no way of loading less data...

Rad [Visual C# MVP] íàïèñà:
Show quote
> On 2 Mar 2007 07:08:38 -0800, OverTheTop wrote:
>
> > When the dataset is too large it thows OutOfMemory Exception although
> > that there is enough momory on the web server, is this a bug in .net
> > or something must be configured?! The Dataset contains near 50 000
> > rows. How can I escape this. Please help?
>
> Well ... for starters I would try to see if I can get the size of the
> dataset down. Is it possible to load less data?
>
> --
> Bits.Bytes
> http://bytes.thinkersroom.com
Author
3 Mar 2007 8:49 AM
Miha Markic [MVP C#]
The other way would be to deal with it as an XML document.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Show quote
"OverTheTop" <vanko.georg***@gmail.com> wrote in message
news:1172848118.781548.201860@30g2000cwc.googlegroups.com...
> When the dataset is too large it thows OutOfMemory Exception although
> that there is enough momory on the web server, is this a bug in .net
> or something must be configured?! The Dataset contains near 50 000
> rows. How can I escape this. Please help?
>
Author
3 Mar 2007 11:57 AM
OverTheTop
Yes I was thinking of something like this...first use
DataSet.WriteXml(tempFile) and then use a XmlDocument to load the
tempFile and get the xml string representation of the DataSet. Is that
what you suggest? Is this gonna solve this issue?



Miha Markic [MVP C#] íàïèñà:
Show quote
> The other way would be to deal with it as an XML document.
>
> --
> Miha Markic [MVP C#, INETA Country Leader for Slovenia]
> RightHand .NET consulting & development www.rthand.com
> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>
> "OverTheTop" <vanko.georg***@gmail.com> wrote in message
> news:1172848118.781548.201860@30g2000cwc.googlegroups.com...
> > When the dataset is too large it thows OutOfMemory Exception although
> > that there is enough momory on the web server, is this a bug in .net
> > or something must be configured?! The Dataset contains near 50 000
> > rows. How can I escape this. Please help?
> >
Author
3 Mar 2007 12:28 PM
Miha Markic [MVP C#]
"OverTheTop" <vanko.georg***@gmail.com> wrote in message
news:1172923026.298833.105280@v33g2000cwv.googlegroups.com...

Yes I was thinking of something like this...first use
DataSet.WriteXml(tempFile) and then use a XmlDocument to load the
tempFile and get the xml string representation of the DataSet. Is that
what you suggest? Is this gonna solve this issue?

Yes, or even less memory problematic if you use XmlReader that doesn't load
everything - it is just some sort of cursor.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
Author
5 Mar 2007 9:51 AM
OverTheTop
Show quote
On Mar 3, 2:28 pm, "Miha Markic [MVP C#]" <miha at rthand com> wrote:
> "OverTheTop" <vanko.georg***@gmail.com> wrote in message
>
> news:1172923026.298833.105280@v33g2000cwv.googlegroups.com...
>
> Yes I was thinking of something like this...first use
> DataSet.WriteXml(tempFile) and then use a XmlDocument to load the
> tempFile and get the xml string representation of the DataSet. Is that
> what you suggest? Is this gonna solve this issue?
>
> Yes, or even less memory problematic if you use XmlReader that doesn't load
> everything - it is just some sort of cursor.
>
> --
> Miha Markic [MVP C#, INETA Country Leader for Slovenia]
> RightHand .NET consulting & developmentwww.rthand.com
> Blog:http://cs.rthand.com/blogs/blog_with_righthand/

this how i do it now

            string xmlDataSet = null;

            string tempFile = Path.GetTempFileName();

            FileInfo fi = new FileInfo(tempFile);

            if(fi.Exists) {

                ds.WriteXml(tempFile);

                using(StreamReader sr = fi.OpenText()) {

                    xmlDataSet = sr.ReadToEnd();
                    sr.Close();
                }

                fi.Delete();


About sr.ReadToEnd() method...can also throw outofmemory exception,
but can I escape this, because String in .Net is stored in the heap
(in memory) so if the hardware can't hold it, noone can. Corrent me if
I am wrong? So is this the best solution I can think of?

AddThis Social Bookmark Button