locked
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. RRS feed

  • Question

  • User1219651576 posted

    I am working with parttions... i have created partitions for table without desibe any size.. when table contains large data when i retrive records through browser then it gives following error:

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.

    Source Error: 

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception
     can be identified using the exception stack trace below.


    Stack Trace: 

    [OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.]
       System.String.GetStringForStringBuilder(String value, Int32 startIndex, Int32 length, Int32 capacity) +29
       System.Text.StringBuilder.GetNewString(String currentString, Int32 requiredLength) +69
       System.Text.StringBuilder.Append(String value) +97
       System.IO.StringWriter.Write(String value) +34
       System.Xml.XmlTextWriter.WriteStartAttribute(String prefix, String localName, String ns) +1073
       System.Data.DataTextWriter.WriteStartAttribute(String prefix, String localName, String ns) +19
       System.Data.DataTextWriter.WriteStartAttribute(String prefix, String localName, String ns) +19
       System.Xml.XmlWriter.WriteAttributeString(String prefix, String localName, String ns, String value) +18
       System.Data.XmlDataTreeWriter.XmlDataRowWriter(DataRow row, String encodedTableName) +434
       System.Data.XmlDataTreeWriter.SaveDiffgramData(XmlWriter xw, Hashtable rowsOrder) +551
       System.Data.NewDiffgramGen.Save(XmlWriter xmlw, DataTable table) +175
       System.Data.DataSet.GetRemotingDiffGram(DataTable table) +135
       System.Data.DataTable.SerializeDataTable(SerializationInfo info, StreamingContext context, Boolean isSingleTable, 
    SerializationFormat remotingFormat) +364
       System.Data.DataTable.GetObjectData(SerializationInfo info, StreamingContext context) +94
       System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter) +7629722
       System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter) +51
       System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) +410
       System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck) +134
       System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph) +13
       System.Web.UI.ObjectStateFormatter.SerializeValue(SerializerBinaryWriter writer, Object value) +842
    
    [ArgumentException: Error serializing value 'Table1' of type 'System.Data.DataTable.']
       System.Web.UI.ObjectStateFormatter.SerializeValue(SerializerBinaryWriter writer, Object value) +3319
       System.Web.UI.ObjectStateFormatter.Serialize(Stream outputStream, Object stateGraph) +110
       System.Web.UI.ObjectStateFormatter.Serialize(Object stateGraph) +57
       System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Serialize(Object state) +4
       System.Web.UI.Util.SerializeWithAssert(IStateFormatter formatter, Object stateGraph) +37
       System.Web.UI.HiddenFieldPageStatePersister.Save() +79
       System.Web.UI.Page.SavePageStateToPersistenceMedium(Object state) +105
       System.Web.UI.Page.SaveAllState() +236
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1099
    Friday, May 18, 2012 1:11 AM

Answers

  • User197322208 posted

    see pagination in

    http://www.asp.net/web-forms

    tutorials.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 18, 2012 5:55 AM

All replies

  • User197322208 posted

    when table contains large data when i retrive records through browser then it gives following error:

    ...
    Exception Details: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown

    Either add more memory to your server, either serialize iteratively small amount of data( if you have 100 records, serialize first 10, then next 10 then ...)

    Friday, May 18, 2012 2:46 AM
  • User1219651576 posted

    if you have 100 records, serialize first 10, then next 10 then ...

    any eaxample?

    i dont know how to do this..

    Friday, May 18, 2012 3:03 AM
  • User197322208 posted

    How do you obtain the datatable?

    Friday, May 18, 2012 3:56 AM
  • User1219651576 posted

    DataTable dt = new DataTable("Tab");
    dt.Clear();
    da.Fill(dt);

    grdDisplay.DataSource = dt;
    grdDisplay.DataBind();

    Friday, May 18, 2012 4:52 AM
  • User197322208 posted

    see pagination in

    http://www.asp.net/web-forms

    tutorials.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 18, 2012 5:55 AM