I posted the same question on http://social.msdn.microsoft.com, but they seem to be less active - so I hope maybe you can help me out.

Around the internet there are plenty questions regarding WebBrowser memory leak problem.

This is how you can confirm the problem: start a new project and add WebBrowser and Timer (shorter delay, will produce faster effect I set mine to 100 ms).

Code:
Public Class Form1

  Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    WebBrowser1.Navigate("www.microsoft.com")
  End Sub

End Class
And beyond the obvious part, which is that page won't load due to insufficient time - you should see a nice steady memory leak - around 8-50 kB for each WebBrowser1.Navigate().

  • Happens on every page I tried it on, even about:blank, seems to depend on website size,
  • Changing browser version has no impact (7, 8, 9),
  • Trying to dispose WebBrowser1 and addind it again to the form won't work,
  • Trying to dispose Form1 and recreating it won't work,
  • Playing with GC won't work,
  • Minimizing and setting process available memory to -1, -1 only reduces physical memory usage, has no impact on virtual memory,
  • Disabling various objects - flash, javascript, images - won't work (no surprise when leak occurs even with about:blank),
  • leak can be measured using all the tools imaginable (I have seen suggestions to use advanced tools over Task Manager - trust me I don't need it when my program crashes after few hours after growing to 1,5 GB of memory)
  • So far the only way to free this memory is to close application and run it again


So, I am sure most of you reading this are well aware of this problem. I mean, there are so many posts about it, it must be either very common or at least well known to community. My question is: can I force WebBrowser to act civilized and prevent memory leak?

Downloading webpage source will not do, I *need* WebBrowser to work - I interact with JavaScript on the website. I also *need* the program running without an interruption. I don't want messy workarounds, like rebooting my application or using Mozilla component.

Yours frustratedly