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

Community
  • 1
  • 1
abhinavp
  • 53
  • 1
  • 6
  • It looks to me like your question is an exact duplicate of the one that you have linked. Are you using this control differently to the way described in that question? – Justin Aug 01 '12 at 16:29
  • Well that thread refers to memory leak an each "Navigate" function call, but for my use case I need to dispose WebBrowser everytime and create a new instance. Still I am facing memory leak. – abhinavp Aug 01 '12 at 16:58
  • possible duplicate of [How to get around the memory leak in the .NET Webbrowser control?](http://stackoverflow.com/questions/8302933/how-to-get-around-the-memory-leak-in-the-net-webbrowser-control) – Judah Gabriel Himango Aug 01 '12 at 17:47

1 Answers1

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.

Community
  • 1
  • 1
aliassce
  • 1,197
  • 6
  • 19