.NET Webbrowser Control and Dispose()

后端 未结 3 1364
生来不讨喜
生来不讨喜 2021-01-14 01:03

I know this is a hot discussed topic with many questions and answers but I still do not find the solution for the following problem:

I have a multi-tab application.

3条回答
  •  不思量自难忘°
    2021-01-14 02:06

    Thanks for your answers. Here what I checked out:

    Calling GC manually:

    • Does only help if I use Webbrowser.Dispose() in before. But this is not a solution because of the session problem.

    Limit Mem Usage:

    • Not a solution. This program should run a whole day with many opening and closing of tabs. If I can not clean the used memory, the memory usage will be too much after some hours..

    about:blank:

    • I called about:blank on Closing the Tab. After DocumentLoaded occurs for this URL I disposed the Webbrowser. Same procedure as calling Dispose directly. Session breaks down.

    Other components:

    • I need to have an IE control in every case because the (proprietary) internet application only supports IE 8 and higher.

    "Using c++ and WinInet":

    • Can I use the C++ Browser in my .net program? I can not switch the whole program to C++. This wouldn't be a solution for me.

    In summary:

    My application works fine without Dispose but has the problem with the increasing memory usage. If we could find a solution for this (which seems to be impossible) it would be the best solution.

    The only thing what would be an acceptable "workaround" for me is to reuse the "closed" webbrowsers. In detail: On every tab close I add the Webbrowser to a List instead of Dispose them. When I need a new tab I take the first out of the list an reuse it and Navigate to the new URL: I tried it out but it seems there is the same problem with the sessions. The sessions in the reused tabs seems to be new again. But I really do not understand why... An suggestions for this, too?

    Another workaround would be to force every Webbrowser object to be a single instance. Is this possible?

提交回复
热议问题