我遍历的div与华廷非常大名单(约3000),我得到的错误:如何解决华廷OutOfMemoryException异常
A first chance exception of type 'System.OutOfMemoryException' occurred in WatiN.Core.dll
System.OutOfMemoryException: Insufficient memory to continue the execution of the program.
at WatiN.Core.UtilityClasses.UtilityClass.TryFuncFailOver[T](DoFunc`1 func, Int32 numberOfRetries, Int32 sleepTime)
at WatiN.Core.Native.InternetExplorer.IEElement.GetWithFailOver[T](DoFunc`1 func)
at WatiN.Core.Native.InternetExplorer.IEElement.GetAttributeValue(String attributeName)
at WatiN.Core.Element.GetAttributeValueImpl(String attributeName)
at WatiN.Core.Component.GetAttributeValue(String attributeName)
at WatiN.Core.Element.get_OuterHtml()
at WatiN.Core.Document.get_Html()
当点击一个div然后让的的HTML浏览器。
有谁知道如何解决内存问题?我希望我可以使用不同的功能或以某种方式分割页面。也许我会需要使用其他的东西比华廷
的代码是:
foreach (Div d in browser.Divs)
{
try
{
d.Click(); // click div
System.Threading.Thread.Sleep(250); //wait for new data to load
string url = "";
if (browser.Html.Contains("http://www.google.com/url?")) // check if an external link exists on the page - this causes the memory exception
{
感谢所有帮助
克里斯
取悦过去包含该代码的完整的方法..这样一看就明白到底什么是你甚至试图做..例如d.Click()什么样的代码背后有发生。这看起来相当凌乱条款代码逻辑 – MethodMan 2011-12-26 00:49:08