2011-12-26 2 views
0

내가 WatiN로 된 div의 매우 큰 목록을 반복하고있어 (3000)와 나는 오류를 받고 있어요 문제를 해결하는 방법 :WatiN에서 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() 

다음의 HTML을 받고 사업부를 클릭 브라우저.

누구든지 메모리 문제를 해결하는 방법을 알고 있습니까? 다른 기능을 사용하거나 페이지를 어떻게 든 분할 할 수 있기를 바랍니다. 아마도 내가 코드가

WatiN

아닌 다른 뭔가를 사용해야합니다 : 어떤 도움

에 대한

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 
          { 

감사 크리스

+0

이 코드가 포함 된 전체 메서드를 지나서보십시오 .. 그래서 도대체 무슨 일이 일어 났는지 이해할 수 있습니다 .. 예를 들어 d.Click()과 같은 코드 숨김이 발생합니다. 코드 로직 – MethodMan

답변

0

메모리 사용량이 1GB를 초과하여 아마도 32 비트 .net 객체 제한을 초과했기 때문에이 경우 Internet Explorer에 문제가있었습니다. 어딘가에.

내 경우에는 64 비트 시스템에서 "고정"(또는 오히려 지연) 문제가 발생합니다.

0

먼저 페이지를 기다릴하지 않을 때 사용자 스레드 수면을 , 당신은 browser.WaitForComplete()

당신은 링크가 특정 페이지로 이동하는 것을 확인하는 경우 직접 브라우저 URL을 확인할 수 있습니다 this : browser.Url.Contains ("address") ...

+0

Chris가 AJAX 또는 유사한 비동기 호출을 기다리면 Thread.Sleep()으로 끝날 수 있습니다. 가장 좋은 방법은 아니지만 WaitForComplete는 AJax-y 로딩을 위해 작동하지 않습니다. – OCary

+0

안녕하세요, thread.sleep을 필요로하는 아약스를 기다리고있었습니다.이 코드를 게시하기에 충분한 코드를 게시해야합니다. – chris

+0

아, 미안합니다. – alonp