Webbrowser control accumulating memory with every use of the Navigate method

Asked

Viewed 43 times

0

I created a program that uses Webbrowser to search for information online (Log in automatically and later bring the page information to the program). The program works perfectly, but it turns out that the program updates the information every 5 minutes and then ends up using the Navigate method every 5 minutes.

WebBrowser webBrowser1 = new WebBrowser(); webBrowser1.Navigate("www.google.com", false);

Above is an example. Every time I use the Navigate method the memory increases and no matter what I do it does not decrease. I tried to use the Dispose method, tried to delete the control... all without success. OBS.: Using Dispose the memory decreases, but always leaves a little more in the memory and, because of this, it ends up accumulating memory.

Would anyone know any way to avoid this increase in memory with each use of the Navigate method?

  • Have you tried instantiating your webBrowser1 variable only if it is not instantiated?

  • Maybe make it static?

  • Present the code of how you are implementing and the evidence of memory consumption.

  • If you are always instantiating a new object, it is normal for the memory to increase. Try to make it a global object, being instantiated only once.

  • I charge only once, as in the example.

  • I edited the previous comment on the same day, but I don’t think it saved... Anyway, I create a global instance and then just use the Navigate method at each time interval and the memory accumulates. If I use Dispose the memory decreases, but there is a "leftover" of memory.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.