Hi
Please note this is done in WPF/c# and not in .net2.0 winforms
I have a ListBox which contains objects of say Class X. Class X contains a BitmapSource object which is displayed in the listbox, so it display similar to '[Image] [Text]'
This is loaded via the use of the 'CreateBitmapSourceFromHBitmap' - note also that i call DeleteHBitmap to delete the handle of the HBitmap during this call, which is well known to do from posts ive seen on google/etc
I have a tree which contains said ListBox in each TreeViewItem - typically the tree has several items loaded. Users can drag/drop these images into different TreeViewItems. To handle these operation i manually call the operations
ItemCollection.RemoveAt
ItemCollection.Insert
to 'move' the images from the ListBox item collection, note when i insert i create a new Class X object to insert into the ListBox item collection
I have noticed i get a consisteny memory leak from calling such operations several times, over the space of 5-10mins of consistent dragging and dropping
My question is:
Am I handling the moving of the BitmapSource's correctly? Is there something im doing to cause the Images to not be fully removed from the ItemCollection?
Or is there something fundamental ive missed?