Possible memory leak with Rad Menu SubItems?

6 posts, 1 answers
  1. Patrick
    Patrick avatar
    43 posts
    Member since:
    Jan 2013

    Posted 13 Jan Link to this post

    Hello,
    Recently we noticed that our product was not up for garbage collection when a user logged out, instead the entire product instance was held in memory. We've isolated it to what seems to be the RadMenu. Specifically the RadMenuItem when used as a SubMenuItem. This appears to happen either with RadMenuItems built in XAML, code behind, or binding to a collection with a template.

    I have sample project to reproduce the issue but I couldn't attach it here. This occurs with the newest version 2016.1.112 and previous 2015.3.1104, I’m not sure of other releases.

     Attached is a PDF of the Instance Retention Graph from a popular memory profiler.

    We have used RadMenus extensively throughout the product and were able to mitigate the issue with manual recursive cleanup by traversing the visual tree to decouple the RadMenuItems, by clearing all RadMenuItems of subitems and then all RadMenu's of all RadMenuItems. This has allowed the vast majority of the product to be collected with the exception of the RadMenuItems items themselves, which appear to be held onto by a ResourceDictionary.

    We haven’t noticed this type of behavior with any other control, either Telerik or ours. Is this supposed to be doing this or are we supposed to do something else to release the memory?

    If you need any additional info, please don’t hesitate to ask. Thank you,

     Patrick

     

  2. Patrick
    Patrick avatar
    43 posts
    Member since:
    Jan 2013

    Posted 13 Jan Link to this post

    Trying attachment again...
  3. DevCraft banner
  4. Answer
    Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 14 Jan Link to this post

    Hello Patrick,

    Thanks for bringing this to our attention.

    We managed to reproduce the issue and I logged it in our internal backlog. What I can suggest you for now as workaround would to either to stop the Animations of the Menu or use the following code before clearing the menu:

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        var grids = xTestContainer.ChildrenOfType<Grid>().Where(x => x.Name == "RootElement");
        foreach (var grid in grids)
        {
            grid.Resources.Clear();
        }
        xTestContainer.Children.Clear();
        //xTestContainer.Child = null;
    }

    Please test the workaround in the sample project and let me know if it will work for you. I have also updated your Telerik points for your involvement.

    Regards,
    Kalin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  5. Patrick
    Patrick avatar
    43 posts
    Member since:
    Jan 2013

    Posted 14 Jan Link to this post

    Kalin,
    Thank you for the quick response. This seems to work very well, I implemented it with an extension method as such:

    1.public static void CleanupRadMenuResources(this RadMenu menu)
    2.{
    3.    var grids = menu.ChildrenOfType<Grid>().Where(x => x.Name == "RootElement");
    4.    foreach (var grid in grids)
    5.    {
    6.        grid.Resources.Clear();
    7.    }
    8.}

     

    The RadMenuItems themselves are now cleaned up. Also noted disabling animation worked as well. Could you please show your recommendation for disabling animation on just the RadMenu instead of using the global code below?

    1.AnimationManager.IsGlobalAnimationEnabled = false;

     

    Could you estimate that this issue with RadMenuItem animation would be fixed in the next major release?

    Thanks again Kalin.

  6. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 19 Jan Link to this post

    Hi Patrick,

    You can stop only RadMenu animations as shown below:

    <telerik:RadMenu telerik:AnimationManager.IsAnimationEnabled="False">
    ...

    As for the issue - currently I cannot commit any time frame. However I also logged it in our Feedback portal, so you can easily track its status on the following link:

    http://feedback.telerik.com/Project/143/Feedback/Details/180571-animationmanager-is-causing-memory-leak-in-radmenuitem-when-the-expand-animation

    If you have any other questions, please do not hesitate to contact us.

    Regards,
    Kalin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  7. Patrick
    Patrick avatar
    43 posts
    Member since:
    Jan 2013

    Posted 19 Jan in reply to Kalin Link to this post

    Kalin,

    Thank you for the update.

    -Patrick

Back to Top
DevCraft banner