473,327 Members | 1,979 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,327 software developers and data experts.

Exception of type System.OutOfMemoryException is thrown

Hi,
There are several pages that occasionally start throwing
System.OutOfMemoryException and "The type initializer for
"Microsoft.Practices.EnterpriseLibrary.Data.Instru mentation.DataCommandFailedEvent
exception."
The problem goes away after iisreset .

- Actually on Excel Exporting this error happens and stops all the
applications in the server
- It exceeds more than 1GB size, i hope so in server
-

How to solve this problem? How to reduce size of Dataset when exporting
to excel file?
Help me out in this...
Thanks in advance

-karups

Oct 18 '06 #1
5 7736
You may wish to clarify what exactly your code is doing... it isn't entirely
clear from the post.

Initial thoughts:
* Are you using Excel directly on the server? Yup, that might not scale so
well...
* Reduce the size of the DataSet =work with less data...
* ...or, work with a "streaming" approach rather than an "in memory"
approach - i.e. it loads a record ([or a few, or dozens, or hundreds, but
not millions] at a time) from the source, processes (writes?) that record /
those records, and *then* moves on. Think IDataReader, Stream, etc

Maybe if you can clarify what you are trying to achieve somebody can suggest
a better approach.

Marc
Oct 18 '06 #2
My application will have a fetch button.
As soon as we click the fetch button..It calls a Stored Procedure.
The stored procedure will return a dataset back(huge on with rows 25000
and col:52)...
I export this dataset to excel using this code

Response.Clear();
Response.AddHeader("content-disposition",
"attachment;filename="+filename+".xls");
Response.Charset = "";
this.EnableViewState=false;
Response.Cache.SetCacheability(HttpCacheability.No Cache);
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new
HtmlTextWriter(stringWrite);
DataGrid myDataGrid=new DataGrid();
myDataGrid.DataSource=dsReport.Tables[1];
myDataGrid.DataBind();
myDataGrid.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();

While doing this i get the OutOfMemoryException..

Oct 18 '06 #3
My application will have a fetch button.
As soon as we click the fetch button..It calls a Stored Procedure.
The stored procedure will return a dataset back(huge on with rows 25000
and col:52)...
I export this dataset to excel using this code

Response.Clear();
Response.AddHeader("content-disposition",
"attachment;filename="+filename+".xls");
Response.Charset = "";
this.EnableViewState=false;
Response.Cache.SetCacheability(HttpCacheability.No Cache);
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new
HtmlTextWriter(stringWrite);
DataGrid myDataGrid=new DataGrid();
myDataGrid.DataSource=dsReport.Tables[1];
myDataGrid.DataBind();
myDataGrid.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();

While doing this i get the OutOfMemoryException..

Oct 18 '06 #4
It seems to be well known issue, but the solution is not so trival
Obviously the reason is that your managed heap is overly fragmented that FW
couldn't find free 64mb heap segment to allocate memory.

There are several descriptions in the net about how to investigate this
problem, especially Tess blog (MS escalation engineer)
I recomend to read this recend article
http://msdn.microsoft.com/msdnmag/is...t/default.aspx that
describes your aspect of problem

--
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche


"karups" wrote:
My application will have a fetch button.
As soon as we click the fetch button..It calls a Stored Procedure.
The stored procedure will return a dataset back(huge on with rows 25000
and col:52)...
I export this dataset to excel using this code

Response.Clear();
Response.AddHeader("content-disposition",
"attachment;filename="+filename+".xls");
Response.Charset = "";
this.EnableViewState=false;
Response.Cache.SetCacheability(HttpCacheability.No Cache);
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new
HtmlTextWriter(stringWrite);
DataGrid myDataGrid=new DataGrid();
myDataGrid.DataSource=dsReport.Tables[1];
myDataGrid.DataBind();
myDataGrid.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();

While doing this i get the OutOfMemoryException..

Oct 18 '06 #5
Thank you.I read the article,That was useful information.
But can you tell me a way to rectify in my application if possible..

Oct 20 '06 #6

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

Similar topics

42
by: cody | last post by:
public DateTime Value { get { try { return new DateTime(int.Parse(tbYear.Text), int.Parse(tbMonth.Text), int.Parse(tbDay.Text)); } catch (FormatException)
40
by: Kevin Yu | last post by:
is it a bad programming design to throw exception in the try block then catch it??
1
by: Ripul Handa | last post by:
Hi We are running IIS 5.0 cluster with cisco local director. We are running a website on 2 webservers and I have been observing that from past few days we have are getting this error message of...
11
by: Pete Davis | last post by:
I have an app that's dealing with a few hundred bitmap thumbnails. I only instantiate the bitmaps that are visible at a given time and dispose of them if they get scrolled out of view. I've used...
1
by: SMG - Idealake | last post by:
Hi all, I am getting following error on my error, what could be the reason? Exception of type System.OutOfMemoryException was thrown. Description: An unhandled exception occurred during the...
3
by: elziko | last post by:
I have a procedure that creates a bitmap of a certain size and then displays it in a 3rd party component. However, if the bitmap is very large then a System.OutOfMemoryException is thrown my...
1
by: karups | last post by:
Hi, There are several pages that occasionally start throwing System.OutOfMemoryException and "The type initializer for...
11
by: Don | last post by:
When using Visual Basic .NET with a reference to Interop.Outlook, is there a way to get more detailed information about an error other than Exception.Message or Exception.ToString? For example,...
1
by: chandhrakv | last post by:
Hi experts, Can any one please respond with the resolution. Machine: WIN2K3, ASP.NET application, .NET 2.0 with June 2007 hotfix installed recently. Facing daily 1000 errors with the same type...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.