Menu

#11 GDI Object leak on Windows

open
nobody
None
9
2007-07-16
2007-07-12
No

wxWebView seems to "leak" GDI objects (I think the wx class is wxGDIObject, which is subclassed by things like wxPen, wxBrush, and wxFont).

One specific reproducible case (on Windows, at least) is during selection:

Open any wxWebView window with a moderately complex webpage. Bring up the Windows task manager and sort the processes by "GDI Objects." (You might have to View->Select Columns to see the "GDI Objects" column.

Then click and drag the mouse over the webpage repeatedly so that the selection changes over and over. The WebView process will quickly jump to the top of the list, and keep rising...depending on which version of Windows its running on, it will crash once it hits a limit.

Discussion

  • Kevin Ollivier

    Kevin Ollivier - 2007-07-16
    • priority: 5 --> 9
     
  • Kevin Ollivier

    Kevin Ollivier - 2007-07-16

    Logged In: YES
    user_id=248468
    Originator: NO

    There seem to be two parts to this; first, we have to implement saving and restoring the DC context ourselves, and my first attempt at that was more an attempt to get things running than a complete solution. Second, and more importantly, looking back on this code I see we're leaking images when we do the drawing. It is probably mostly this that is causing the GDI object count to keep growing so rapidly.

    Unfortunately, when I tried to fix this problem, I came across what looks to be a nasty threading bug. Any attempts to delete the wxBitmap after drawing it to the screen lead to crashes later on, in various places. Basically, they all deal with a data structure that was initially created properly suddenly becoming invalid, or becoming unable to access certain internal data structures. I've been trying to track this down, but it is taking time. :-/ I'm fairly certain it is related to something CURL is doing, but I can't seem to get further than that. In the meantime, I committed some code to clean up memory handling as best I can as well as to make some notes and add asserts in an attempt to better pinpoint where the problem is, but in any case, it may take some time to resolve this issue. I wanted to update you guys so you know what's going on.

     

Log in to post a comment.