Home » , , , » Out of memory exception during XML serialization

Out of memory exception during XML serialization

Written By M.L on வியாழன், 19 ஜனவரி, 2012 | ஜனவரி 19, 2012

We have a web application which runs on IIS and a 32 bit OS. We often see OutOfMemory exception logged in event viewer. If we retry the task when we get this issue, the task will complete successfully. So we are not sure what is causing this as it is not consistent. See below exception copied. Please let me know if you have faced this kind of issue earlier and also the fix applied. Thanks in advance for your help.



Exception Type: System.OutOfMemoryException
Message: Exception of type 'System.OutOfMemoryException' was thrown.
Data: System.Collections.ListDictionaryInternal
TargetSite: System.String GetStringForStringBuilder(System.String, Int32, Int32, Int32)
HelpLink: NULL
Source: mscorlib

StackTrace Information
*********************************************
   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(Char[] value, Int32 startIndex, Int32 charCount)
   at System.IO.StringWriter.Write(Char[] buffer, Int32 index, Int32 count)
   at System.IO.TextWriter.Write(Char[] buffer)
   at System.IO.TextWriter.WriteLine()
   at System.Xml.XmlTextWriter.Indent(Boolean beforeEndElement)
   at System.Xml.XmlTextWriter.AutoComplete(Token token)
   at System.Xml.XmlTextWriter.WriteStartElement(String prefix, String localName, String ns)
   at System.Xml.XmlWriter.WriteElementString(String localName, String ns, String value)
   at System.Xml.Serialization.XmlSerializationWriter.WriteElementString(String localName, String ns, String value, XmlQualifiedName xsiType)
   at System.Xml.Serialization.XmlSerializationWriter.WriteElementString(String localName, String ns, String value)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterListControlQuestionChangeOptions.Write2_QuestionOption(String n, String ns, QuestionOption o, Boolean isNullable, Boolean needType)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterListControlQuestionChangeOptions.Write3_Item(String n, String ns, ListControlQuestionChangeOptions o, Boolean isNullable, Boolean needType)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterListControlQuestionChangeOptions.Write4_Item(Object o)


ANSWER 1:
This seems to be problem related to LOH( large Object heap) fragmentation. A memory dump of CLRprofiler can help you debug the problem further.

Please refer this
http://connect.microsoft.com/VisualStudio/feedback/details/521147/large-object-heap-fragmentation-causes-outofmemoryexception
http://blogs.msdn.com/b/dau-blog/archive/2011/10/03/hidden-treasures-in-windbg-gt-save-clrprofiler-compatible-files-from-memory-dumps.aspx
http://www.simple-talk.com/dotnet/.net-framework/the-dangers-of-the-large-object-heap/
http://msdn.microsoft.com/en-us/magazine/cc163491.aspx
ANSWER 2:
http://blogs.msdn.com/b/tess/archive/2009/08/10/why-do-i-see-executionengineexception-stackoverflowexception-and-outofmemoryexception-on-the-heap-when-debugging-net-applications.aspx
Why do I see ExecutionEngineException, StackOverflowException and OutOfMemoryException on the heap when debugging .net applications?
These 3 exceptions (ExecutionEngineException, StackOverflowException and OutOfMemoryException) are very special in the sense that it would be impossible to create an object of type OutOfMemoryException when you are in an OOM situation, as that would fail with yet another OOM.  In the same way you can’t create a StackOverflowException object when you are running into a stack overflow as this would require a call to its constructor which is impossible when the stack is overflowing.


http://blogs.msdn.com/b/tess/archive/2008/09/02/outofmemoryexceptions-while-remoting-very-large-datasets.aspx

OutOfMemoryExceptions while remoting very large datasets

Note : Provide your comments by clicking below options! Thanks ! :)

0 comments:

கருத்துரையிடுக

Popular Posts

General Category