我有一个(x64)程序,它消耗大量内存。我在
我还在app.config中设置了
当我运行程序时,它会消耗18 GB的内存,然后就会出现异常。
win server 2008 R2 SP1
上运行它,使用了48 GB RAM(64 bit)
,.net frame work 4.5
。我还在app.config中设置了
gcAllowVeryLargeObjects = true
。当我运行程序时,它会消耗18 GB的内存,然后就会出现异常。
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()
尽管我们还剩下30GB的内存,但它仍然提示“内存不足”的错误信息。这是.NET应用程序的限制还是服务器的问题?
StringBuilder.ExpandByABlock
的源代码 - 它在某些情况下故意抛出OOM异常。 - mikalai