TabControl and collecting unused resources

2 posts, 0 answers
  1. Goran
    Goran avatar
    77 posts
    Member since:
    Feb 2011

    Posted 14 Aug 2012 Link to this post


    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.

  2. Hristo
    Hristo avatar
    352 posts

    Posted 17 Aug 2012 Link to this post


    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.

    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft R3 2016 release webinar banner
Back to Top