0

My c# application uses .net WebBrowser. I need to close child control everytime and I have noticed WebBrowser is not getting disposed and RAM consumption is increasing heavily with each call (around 10 mb on each new control declaration) and application crashes in sometime with OutOfMemoryException. Searched over forums but couldn't find a clean solution. Tried SetProcessWorkingSetSize(pHandle, -1, -1); but it doesn't reduce virtual memory though RAM uses will be reduced and its not a clean way of overcoming the issue.

Seems this issues exists since years, for more details look at this thread How to get around the memory leak in the .NET Webbrowser control?

Any suggestions ? Tried almost everything but no success yet.

Thanks,

Abhinav

4

1 回答 1

1

I don't know whether your situation is similiar to mine but I have wasted three days for that weird problem. My application was performing a search on a web page and my code was like that;

1.Open web page
for(1000 times)
{
2.Write input and click search button.
3.Check the result.
}

As you see my program opens the web page and makes repeated searches.Here opening the page (navigaiton) occurs only one time. My program's memory consumption was continuously increasing even above 1 GB! Then I tried putting the navigation inside the loop it worked.

for(1000 times)
{
1.Open web page
2.Write input and click seach button.
3.Check the result.
}

I exactly don't know the reason but reusing the same page for a long time was the cause of my problem. I hope it helps.

于 2012-10-13T11:50:03.000 回答