我有一個程序(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