gpt4 book ai didi

c# - HtmlAgilityPack 的 HtmlDocument 中的 System.OutOfMemoryException

转载 作者:行者123 更新时间:2023-11-30 16:26:14 25 4
gpt4 key购买 nike

using (Stream reader = propertyBag.GetResponse())
{
reader.Seek(0, SeekOrigin.Begin);
htmlDoc.Load(reader, true);
}

但是 htmlDoc.Load(reader, true);抛出这个错误:

An unhandled exception of type 'System.OutOfMemoryException' occurred in mscorlib.dll

我们有每天 24 小时运行并检查一些 html 数据的程序。它工作了几个小时,然后我们收到此错误。错误总是与 HtmlAgilityPack 的 HtmlDocument 相关。

如何防止这种情况?

最佳答案

我会使用内存分析器来检查哪些对象没有被释放。可能 Agility Pack 有内存泄漏或者您使用它的代码有。

我用过的最好的分析器之一是 dotTrace ,它允许您在不同的时间点拍摄两个快照,比较它们并显示未处理的对象。

关于c# - HtmlAgilityPack 的 HtmlDocument 中的 System.OutOfMemoryException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9014611/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com