Take the 2-minute tour ×

I'm developing a Smart Device app in the .NET CF 3.5 and have been struggling to resolve some strange memory leaks.

I put together a very basic app demonstrating the leak in question. The full AppVerifier log is also in repo.


So far I've been using the AppVerifier tool from Platform Builder and it shows a Brush being created but not disposed of by the compact framework. I can recreate the issue by selecting one item, then a different item from the ComboBox, then closing the application. Repeating this results in multiple brushes being created but not disposed.

I've tried explicitly disposing the ComboBox, but I have the same result. Any ideas on how to deal with this, other than writing my own control from scratch?

Tailed log:

    | shim_usergdi.dll 4 | 1 kernel.dll 8011a2d0'   0x400251dc: coredll.dll!(null) + 151dch
    | shim_usergdi.dll 4 | 1 kernel.dll 8011a2d0'   0x41e1b254: netcfagl3_5.dll!(null) + 1b254h
    | shim_usergdi.dll 4 | 1 kernel.dll 8011a2d0'   0x41e1b2dc: netcfagl3_5.dll!(null) + 1b2dch
    | shim_usergdi.dll 4 | 1 kernel.dll 8011a2d0'   0x41e1b3dc: netcfagl3_5.dll!(null) + 1b3dch
    | shim_usergdi.dll 4 | 1 kernel.dll 8011a2d0'   0x41e1b4bc: netcfagl3_5.dll!(null) + 1b4bch
    | shim_usergdi.dll 4 | 1 kernel.dll 8011a2d0'Un-freed items:
    | shim_usergdi.dll 4 | 1 kernel.dll 8011a2d0'   0x0010147a   CreateSolidBrush PerfCount: 2383733220 
share|improve this question
add comment

1 Answer

This is a total shot in the dark. My understanding of the combobox control is that the drop down menu is a listbox control. Since you are finding that the brush is being created when you change the visual state of the dropdown (changing the selection in the dropdown). The problem might be in the listbox not the combobox. Can you recreate the same issue just a listbox control? If not the question might be, is there something that the managed code of the listbox is doing that the combobox is not to properly release resources. If the two controls exhibit the same problem, then the problem may not be in the control's managed code.

Another thing you could try is override the dispose method and send a WM_NCDESTROY message to your combobox (using PInvoke + SendMessage or use reflection to call WndProc). I don't know why this would work if conventional methods fail, but trial and error might be your best shot.

share|improve this answer
add comment

Your Answer


