Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# HtmlAlityPack的HtmlDocument中的System.OutOfMemoryException_C# - Fatal编程技术网

C# HtmlAlityPack的HtmlDocument中的System.OutOfMemoryException

C# HtmlAlityPack的HtmlDocument中的System.OutOfMemoryException,c#,C#,但是htmlDoc.Load(reader,true);抛出此错误: 发生“System.OutOfMemoryException”类型的未处理异常 在mscorlib.dll中 我们有一个每天24小时运行的程序,可以检查一些html数据。它工作了几个小时,然后我们得到了这个错误。错误总是与HtmlAlityPack的HtmlDocument相关 如何防止这种情况发生?我将使用内存探查器检查哪些对象未被处置。也许Agility Pack有内存泄漏,或者使用它的代码有内存泄漏 我使用过的最好的分析

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

发生“System.OutOfMemoryException”类型的未处理异常 在mscorlib.dll中

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


如何防止这种情况发生?

我将使用内存探查器检查哪些对象未被处置。也许Agility Pack有内存泄漏,或者使用它的代码有内存泄漏


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

html文档有多大?您正在处理HtmlDocument对象吗?当这种情况发生时,内存是否真的增长到了不切实际的数量,或者。。。?(OOM并不总是与内存负载有关)这只是一个猜测,但我想你可能内存不足。我正在测试的这台计算机中有4 gb的ram@傻瓜不,我不这么认为。在何处使用dispose()?我搜索但无法处理HtmlDocument。HtmlDocument中不支持Dispose…可能不是挂在内存中的
HtmlDocument
实例。这不是调用Dispose()方法的情况,而是丢失对某些对象的引用,以便GC可以回收它们。
using (Stream reader = propertyBag.GetResponse())
{
    reader.Seek(0, SeekOrigin.Begin);
    htmlDoc.Load(reader, true);
}