This is a migrated thread and some comments may be shown as answers.
TabControl and collecting unused resources
1 Answer 14 Views
This is a migrated thread and some comments may be shown as answers.
Goran
Top achievements
Rank 1
Goran asked on 14 Aug 2012, 06:16 PM
Hi,

In your MVVM binding example from the Demos you create tabs using data templates. If you add desrtructor for TabViewModel, it will not fire until application is closed, even if you call GC.Collect(). Why is this happening and what is holding the resources from being freed.

If you fo the same for the regular view, and close it, destructor for ViewModel will fire normally.

The example I am referring is called DataBinding, under TabControl.

Regards,
Goran

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 17 Aug 2012, 01:52 PM
Hello,

I've managed to isolate the memory leak issue. The view model is not collected because of e reference to the last clicked (respective) TabItem hold by the TabControl.
When in the TabItem header there is a button that removes the item on click, this reference is not cleared (there is no MouseLeftButtonUp event) and the view model stays in the heap.

The fix, will be present in our next official Q2 SP2 2012 release in September.

About the concrete example, there is an issue with detaching from the CollectionChanged event of the parent view model. This should be done in the Dispose method in order for the view models to be garbage collected.

Regards,
Hristo
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Asked by
Goran
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or