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
7 Answers, 1 is accepted
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
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.
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
Kalin,
Thank you for the update.
-Patrick
Any update on this?
I just found another memory leak in the RadMenu related to subitem tooltips. I will create a support ticket for that separately.
Thanks,
Patrick
The AnimationManager issue is not fixed yet - please follow the item in order to get notified once its status changes.
If you have any other questions or concerns, please let us know.
Regards,
Kalin
Progress Telerik