Pregunta

In C# I use as a web-browser control ( Watin browser control ) where I run this control into another thread of the main thread.

After a few hours, a memory leak is created.

There is another post ( here : How to Fix the Memory Leak in IE WebBrowser Control? or How to get around the memory leak in the .NET Webbrowser control?) that suggests to call "SetProcessWorkingSetSize" from KERNEL32.DLL.

The workaround is to minimize the winform of web-browser control.

So my question is: if there is another way to solve this problem? and if not, if I use an alternative web-browser control like mozilla-gecko I will solve this memory-leak.

¿Fue útil?

Solución

The solution is to call the garbage collector & force the Windows OS to clean the memory. For example into finally you can write :

finally
{
    GC.Collect();
    GC.WaitForPendingFinalizers();

    EmptyWorkingSet(GetCurrentProcess());
}

EmptyWorkingSet forces the OS to clean the memory.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top