Click here to Skip to main content
14,450,692 members
Rate this:
Please Sign up or sign in to vote.
I have a program(x64) that consumes a large amount of memory. I am running it on win server 2008 R2 SP1 with 48 GB RAM(64 bit) .net frame work 4.5

I have also set gcAllowVeryLargeObjects = true in app.config.

When i run the program it consumes 18 GB memory after that it gives exception

System.OutOfMemoryException: Insufficient memory to continue the execution of the program.
at System.Text.StringBuilder.ExpandByABlock(Int32 minBlockCharCount)
   at System.Text.StringBuilder.Append(Char* value, Int32 valueCount)
   at System.Text.StringBuilder.Append(String value)
   at System.Xml.XmlTextEncoder.Write(String text)
   at System.Xml.XmlTextWriter.WriteWhitespace(String ws)
   at System.Xml.XmlElement.WriteElementTo(XmlWriter writer, XmlElement e)
   at System.Xml.XmlNode.get_OuterXml()
   at System.Security.Cryptography.Xml.Utils.PreProcessElementInput(XmlElement e
   lem, XmlResolver xmlResolver, String baseUri)
   at System.Security.Cryptography.Xml.Reference.CalculateHashValue(XmlDocument
   document, CanonicalXmlNodeList refList)
   at System.Security.Cryptography.Xml.SignedXml.BuildDigestedReferences()
   at System.Security.Cryptography.Xml.SignedXml.ComputeSignature()

Its giving the "Insufficient memory" however we still have 30 GB memory free . Is it the limit of .net application or the server that giving me this error.
Bernhard Hiller 30-Sep-13 3:06am
Is that XML file larger than 2 GB (i.e. Int32.MaxValue)?
Mehdy Moini 30-Sep-13 3:07am
Sometimes this error is refer to your Kernel memory or Pool memory, not your memory!
Do you use Message queue in your application?

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You are definitely doing something wrong if you are signing a 18gb xml.

Try doing things in smaller pieces if it is necessary.

The Xml cryptography library is not designed for such usecases.
abhijeetyadav 30-Sep-13 5:14am
XML file size is 2 GB its taking 18gb while processing it

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100