我有一个程序(x64)会消耗大量内存。 我在win server 2008 R2 SP1
上运行它48 GB RAM(64 bit)
,.net frame work 4.5
。即使30 GB内存空闲,内存异常也不充足
我也曾在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()
它给人以“内存不足”,然而,我们仍然有30 GB的内存免费。 是.net应用程序或服务器给我这个错误的限制。
它可能是碎片问题,如果您强制GC发生错误?或者可能是这样的:http://stackoverflow.com/a/7537821/212121 – Giedrius
通常框架抛出的OOM没有堆栈。查看'StringBuilder.ExpandByABlock'源代码 - 它在某些情况下故意抛出OOM。 – mikalai