質問

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.

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top