wxCheckListBox leaks

BlitzMax Forums/Brucey's Modules/wxCheckListBox leaks

DavidDC(Posted 2008) [#1]
I seem to have uncovered a leak in wxCheckListBox (running in XP). I'd really appreciate it if others could run this code to confirm.

I'm getting a steady 20K leak in task manager - with the GCMemAlloced() printout looking fine.

Worse, if I comment out Clear() and uncomment the DeleteItem() code the leak remains, and the app auto-exits to desktop with nary a complaint after 250 iterations! Most unsettling...

All help much appreciated! Perhaps there's something wrong with my code?




Pete Rigz(Posted 2008) [#2]
hmm seems to happen here too, on Vista. Looking at the description for destroy it says that they're added to a list to be removed at idle time after all events are processed but it seems they not for some reason. I wonder if this is for anything that extends wxwindow or some something specific to do with the listboxes?

Mine didn't crash though after doing what you said.

Incidentally your example wouldn't run before importing brl.standardio for the print command.


DavidDC(Posted 2008) [#3]
Thanks for checking Pete. I've added that extra Import.

If I comment out the .Append line the leak vanishes - so the actual listbox control is being destroyed I think, just not its contents. User data doesn't seem involved as Appending with a NULL second arg still leaks.

Edit:

I can add that simply creating/populating and destroying a CheckListBox in a closed loop doesn't leak when I attempt this in C++ as follows:



Which suggests to me there's not any issue with wxWidgets not having space/time to call its low level cleanup code.


DavidDC(Posted 2009) [#4]
Just a follow-up on this.

My current workaround has been to write my own CheckListBox simply by extending wxListCtrl and manually setting an empty box image/ticked box image for each row via the imagelist functionality.

You then use wxListItem.GetImage to test the check state of any given row - so you don't even need to add any extra data structures.

The result is leak free and nigh indistinguishable from the real control.