I'm iterating over a very large list of divs with WatiN (about 3000) and I'm getting the error:
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()
When clicking a div then getting the html of the browser.
Does anyone know of how to fix the memory issue? I am hoping I can use a different function or split the page somehow. Perhaps I will need to use something other than WatiN
The code is:
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
{
Thanks for any help
Chris
In this case it was a problem with Internet Explorer as the amount of memory it used went beyond 1GB and presumably hitting the 32-bit .net object limit somewhere.
In my case running on a 64-bit system "fixed" (or rather, delayed) the issue.