List Info

Thread: Re: Re: System.OutOfMemoryException




Re: Re: System.OutOfMemoryException
country flaguser name
United States
2007-09-24 07:18:04

Thanks for the responses. I will redesign the code accordingly. I have learned about memory based objects in DOM through this list.

Regards
Uma

Dean Fiala < dfiala%40gmail.com">dfialagmail.com> wrote:
"Doctor, it hurts when I do this.";
"Don't do that.";

XML is wonderful thing, but it is very heavy. A 240,000-record mass of data
is going to suck up all your memory, as you have found out. Morevover, you
probably don't want whoever is consuming the service to have to wait for the
web service to return that much data (i'm guessing its more than 500 MB).
So, it is time to redesign your web service to return smaller amounts of
data.

If your web service consumers really need all 240,000 records, have them ask
for it and receive it in chunks. The first response can return say 5,000
records tell them how many calls they will need to get the rest.

If they only need small bits to begin with you can change your method to
allow the consumer to be more specific about what they want.

On 9/23/07, Uma Ayyanathan < uayyanathan%40yahoo.com">uayyanathanyahoo.com> wrote:
&gt;
> The situation I have is:
>
> I need to return a XmlNode or XmlDocument from a webservice.
>
> Following is the procedureI have in my webmethod:
>
&gt; [WebMethod]
> public XmlNode GetXmlById()
> {
> //Get data from sql server
&gt; -------------------------------
> xmlRead = comm.ExecuteXmlReader();
> XPathDocument xPath = new XPathDocument(xmlRead);
> XPathNavigator xNav = xPath.CreateNavigator();
> XmlDocument xDoc= new XmlDocument();
>; XmlNode root = xDoc.CreateElement(&quot;NewDataSet");
> root.InnerXml = xNav.OuterXml; ------------ method fails here.
&gt; System.OutOfMemoryException is thrown at this line
>; xDoc.AppendChild(root);
> return root;
&gt; ---
> }
>
> How can I use XmlTextReader/XmlTextWriter to store in
> XmlDocument/XmlNode?
>
&gt; Thanks for your feedback in advance.
>
>; Thanks
&gt; Uma
>
> Charles Carroll < 911%40learnasp.com">911learnasp.com> wrote:
&gt; Use the XMLTextWriter object
&gt; it is not Memory based
&gt; unlike the other XML objects and can transmit large amounts of data.
&gt;
> On 9/22/07, Uma Ayyanathan < uayyanathan%40yahoo.com">uayyanathanyahoo.com> wrote:
&gt; >
>; >
>; >
>; >
>; >
>; >
>; > Hi all,
>; >
>; > I had tried a couple of methods to convert the records returned from Sql
> Server into XML.
>; >
>; > 1. The stored procedure returns about 240,000 records from SQL Server
&gt; (2000) and I dump it in a dataset. I had used the method dataset.getXml()
&gt; to return the data in XML. It throws System.OutOfMemoryException!
> Therefore, I tried using the following method.
> >
>; > 2. I used XMLReader to read XML data returned by SqlServer. Here is the
> code:
&gt; >
>; > xmlRead = comm.ExecuteXmlReader();
> > XPathDocument xPath = new XPathDocument(xmlRead);
> > XPathNavigator xNav = xPath.CreateNavigator();
> > XmlDocument xDoc= new XmlDocument();
>; > XmlNode root = xDoc.CreateElement(&quot;NewDataSet");
> > root.InnerXml = xNav.OuterXml; ------------ method fails here.
&gt; System.OutOfMemoryException is thrown at this line
>; > xDoc.AppendChild(root);
> >
>; > When I stepped through the code, I could see there is data returned for
> xNav.OuterXml. But when I place it in the XmlNode, it blows out with
>; System.OutOfMemoryException error.
&gt; >
>; > Can you help me find a solution to this baffling problem?
> >
>; > Thanks
&gt; > Uma
>
>
&gt;
>
>
&gt; ---------------------------------
> Yahoo! oneSearch: Finally, mobile search that gives answers, not web
> links.
&gt;
> [Non-text portions of this message have been removed]
>
>;
>
>
> Yahoo! Groups Links
&gt;
>
>
>;

--
Dean Fiala
Very Practical Software, Inc
Now with Blogging...
http://www.vpsw.com/blogbaby
Microsoft MVP

[Non-text portions of this message have been removed]

---------------------------------
Tonight's top picks. What will you watch tonight? Preview the hottest shows on Yahoo! TV.

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )