将字符串解析为XElement抛出system.out of.memory异常 [英] Parsing string to XElement throwing system.out of.memory exception
本文介绍了将字符串解析为XElement抛出system.out of.memory异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我试图解析一个有大量文本的字符串值时,我得到系统内存异常。
我使用下面的代码。
foreach (KeyValuePair< string,> 项 in newXMlValue)
{
XElement node =( from c in orderXML.Descendants(item.Key)选择 c).FirstOrDefault();
if (!object.Equals(node, null ))
{
XElement xmlValue = XElement.Parse(item.Value.ToString()); // 这里我得到系统内存异常
node.ReplaceWith (xmlValue)
}
}
请帮我解决这个问题。 />
谢谢
解决方案
适用于您的问题的文章 - Out of Memory Exception:一个简单的string.Split如果使用不当可能会致命 [ ^ ]
FYI
疑难解答异常:System.OutOfMemoryException [ ^ ]
高级.NET调试:托管堆和垃圾收集 [ ^ ]
Hi,
When I am trying to parse a string value which has a huge text, then I am getting system out of memory exception.
I am using below code.
foreach (KeyValuePair<string,> item in newXMlValue)
{
XElement node = (from c in orderXML.Descendants(item.Key) select c).FirstOrDefault();
if (!object.Equals(node, null))
{
XElement xmlValue = XElement.Parse(item.Value.ToString()); // Here I am getting system out of memory Exception
node.ReplaceWith(xmlValue)
}
}
Please help me to solve this problem.
Thanks
解决方案
Suitable article for your question - Out of Memory Exception: A simple string.Split can become fatal if not used properly[^]
FYI
Troubleshooting Exceptions: System.OutOfMemoryException[^]
Advanced .NET Debugging: Managed Heap and Garbage Collection[^]
这篇关于将字符串解析为XElement抛出system.out of.memory异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文