Out of Memory Exception

Feb 8, 2011 at 1:21 PM
Edited Feb 8, 2011 at 1:26 PM

Hi,

I am using this control (and its sweet) in a project. It works fine for all scenarios but one where we really have a large table with 5000 records. When we try to export the same, there is an Out of Memory exception in the page. The exception is at the following line

table.RenderControl(htw)

The stack trace is pasted below. I didn't find an Out of Memory exception reference in the forums and wondering if there is a way to overcome this. It is happening internally inside the RenderControl method and doesn't happen when I debug through Cassini. The file is 4.8 MB and I am wondering if this has to do with any IIS settings as well. Any pointers would be much appreciated.

<Begin Stack trace>

"Timestamp: 2/8/2011 12:58:59 PM
Message: HandlingInstanceID: 0cce760a-f5a2-4af6-922b-016bc059aab3
An exception of type 'System.OutOfMemoryException' occurred and was caught.
---------------------------------------------------------------------------
02/08/2011 18:28:59
Type : System.OutOfMemoryException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Exception of type 'System.OutOfMemoryException' was thrown.
Source : mscorlib
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : System.String GetStringForStringBuilder(System.String, Int32, Int32, Int32)
Stack Trace :    at System.String.GetStringForStringBuilder(String value, Int32 startIndex, Int32 length, Int32 capacity)
   at System.Text.StringBuilder.GetNewString(String currentString, Int32 requiredLength)
   at System.Text.StringBuilder.Append(String value)
   at System.IO.StringWriter.Write(String value)
   at System.Web.UI.HtmlTextWriter.Write(String s)
   at System.Web.UI.LiteralControl.Render(HtmlTextWriter output)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.WebControls.TableCell.RenderContents(HtmlTextWriter writer)
   at System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer)
   at System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   at System.Web.UI.WebControls.Table.RenderContents(HtmlTextWriter writer)
   at System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   at KrishLabs.Web.Controls.ExportToExcel.ExportGridView.Export(String fileName, GridView gv, Boolean ApplyStyling, Boolean EnableHyperLinks, SortedList`2 ColumnsToExclude, String ContentEncoding, String Charset) in ~~~~~~\ExportoExcel\ClusterControls.vb:line 319
   at KrishLabs.Web.Controls.ExportToExcel.ExportToExcel_OnClick(Object Sender, EventArgs e) in ~~~~~~\ExportoExcel\ClusterControls.vb:line 229
   at KrishLabs.Web.Controls.ExportToExcel.ExportToExcel_Click(Object sender, EventArgs e) in ~~~~~~\ExportoExcel\ClusterControls.vb:line 144
   at System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e)
   at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
   at KrishLabs.Web.Controls.ExportToExcel.RaisePostBackEvent(String eventArgument) in ~~~~~~~\ExportoExcel\ClusterControls.vb:line 260
   at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.Page.Rais"

<End Stack trace>