Memory Leak in RadWindow :(

14 posts, 0 answers
  1. trung
    trung avatar
    3 posts
    Member since:
    May 2009

    Posted 21 Jul 2011 Link to this post

    Hi Telerik Dev team,

    I'm a Silverlight Developer. After I upgraded Telerik Q2 2011, my form using RadWindow cannot Dispose when Close. Can you help me. :(
  2. Sam
    Sam avatar
    19 posts
    Member since:
    May 2009

    Posted 25 Jul 2011 Link to this post

    Hi Telerik,

    I am also experiencing this.

    I was trying to track down where and it seems like SizedChanged event handler doesn't get removed from the root visual when the window is closed.

    I am guessing this happens in PopupWindowHost?

    Sam
  3. DevCraft banner
  4. George
    Admin
    George avatar
    1332 posts

    Posted 27 Jul 2011 Link to this post

    Hello Sam,

     
    Thank you for contacting us.

    We are aware of this issue and it is fixed for our internal build. Could you please download our latest internal build binaries and give it a try? Please, do not hesitate to contact us if you continue experience any problems with our RadControls.


    All the best,
    George
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  5. trung
    trung avatar
    3 posts
    Member since:
    May 2009

    Posted 27 Jul 2011 Link to this post

    Thanks Sam and George,

    I'll download and install internal build when it available
  6. Raphael
    Raphael avatar
    15 posts
    Member since:
    Jan 2011

    Posted 28 Jul 2011 Link to this post

    Hi,

    I am also facing the memory leak problems on my radwindows...
    My application memory still increases and never frees.
    Do you know when the latest internal build will be available ?

    I use also radtreeview with telerik HierarchicaDataTemplate and the memory is never released..

    Did you check you memory tests onto your controls ?
    Are there good pratices that the memory is freed after closing windows ?

    Raphael
  7. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 02 Aug 2011 Link to this post

    Hi Raphael,

     
    The internal build is already released, so you could download it as well. The RadWindow control disposes itself when the GC collect it automatically. Please, note you don't keep any reference to that RadWindow, because this will prevent the object from disposing.

    We are not aware of any memory leaks in the RadTreeView control.  Can you give us more details about the scenario in which you found them. Also, is your RadTreeView placed inside the RadWindow? If it is can you check if the latest internal build will fix the issue. Also, can you reproduce the RadTreeView memory leak when the control isn't placed inside a RadWindow control? And when you say that the memory is never released, do you mean managed or unmanaged memory.

    If you can give us more details about the definition of the RadTreeView control and the scenario where it is used, we will be able to further test it for memory leaks. Any additional info that you can give us will be highly appreciated. Thank you in advance for your cooperation.

    Kind regards,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  8. Raphael
    Raphael avatar
    15 posts
    Member since:
    Jan 2011

    Posted 03 Aug 2011 Link to this post

    The fix from internal build 01444RadControls_for_Silverlight4_2011_2_0801_DEV_hotfix does not improve my memory problems...
    Closing my window does not relase memory used from controls and objects instantiated by the window. I don't know how to do to detect what and why objects are not disposed...

    Moreover, the fix comes with modifications on other controls that I have no time to check for the moment in all my application (example : the RadNumericUpDown.NumberFormatInfo is no more instantiated by default, it is null now) so I undo my replacement of binaries to get the original version.

    I am gonna make simple projects to check my memory problems ton know if it comes from UI or ViewModel objects which are not disposed...
  9. Raphael
    Raphael avatar
    15 posts
    Member since:
    Jan 2011

    Posted 03 Aug 2011 Link to this post

    I made a sample with a simple button that iniates a new RadWindow and calls ShowDialog on it.
    The RadWindow contains a Radtreeview expanded with about 30 items.

    At the beginning, the application takes 30Mb RAM (MemTest1.JPG)
    1. Clic to the button, the window opens : 44Mb (MemTest2.JPG)
    2. Close the window : 44 Mb (MemTest3.JPG)
    3. Clic to the button, the window opens : 51Mb
    4. Close the window : 51Mb
    5. Clic to the button, the window opens : 56Mb
    6. ...

    The problem does not come from the 5Mb into this test but in my real application, it's about 30Mb used for each childwindow opened to reach 900Mb !!

    Here are codes for the sample :

    MainPage.xaml

    <UserControl x:Class="MemoryTest.MainPage"
                 xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        mc:Ignorable="d"
        d:DesignHeight="300" d:DesignWidth="400">
     
        <Grid x:Name="LayoutRoot" Background="White">
            <telerik:RadButton Height="20" Width="100" Click="RadButton_Click">Test</telerik:RadButton>
        </Grid>
    </UserControl>

    MainPage.xaml.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
     
    namespace MemoryTest
    {
        public partial class MainPage : UserControl
        {
            public MainPage()
            {
                InitializeComponent();
            }
     
            private void RadButton_Click(object sender, RoutedEventArgs e)
            {
                winTree win = new winTree();
                win.ShowDialog();
            }
        }
    }

    winTree.xaml

    <telerik:RadWindow x:Class="MemoryTest.winTree"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
                          xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
               Width="400" Height="300"
               Header="winTree">
        <Grid x:Name="LayoutRoot" Margin="2">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <telerik:RadTreeView>
                <telerik:RadTreeView.Items>
                    <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem IsExpanded="True" Header="Test">
                        <telerik:RadTreeViewItem IsExpanded="True" Header="Test">
                        <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                        <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                    </telerik:RadTreeViewItem>
                    </telerik:RadTreeViewItem>
                    <telerik:RadTreeViewItem IsExpanded="True" Header="Test">
                        <telerik:RadTreeViewItem IsExpanded="True" Header="Test">
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                            <telerik:RadTreeViewItem Header="Test"></telerik:RadTreeViewItem>
                        </telerik:RadTreeViewItem>
                    </telerik:RadTreeViewItem>
                </telerik:RadTreeView.Items>
            </telerik:RadTreeView>
            <Button x:Name="CancelButton" Content="Cancel" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" />
            <Button x:Name="OKButton" Content="OK" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1" />
        </Grid>
    </telerik:RadWindow>


        



  10. wind wang
    wind wang avatar
    5 posts
    Member since:
    Apr 2010

    Posted 03 Aug 2011 Link to this post

    It seems the RadWindow in Q2 changed a lot, and comes with some bugs...
  11. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 04 Aug 2011 Link to this post

    Hello Everybody,

     Yes, we did a lot of changes to the RadWindow control which caused some bugs and leaks, but the memory leak you are talking about is fixed in internal build you are testing with. The way you are observing the memory is not right way to investigate memory leaks as the Garbage Collection collects the memory on demand. This means that window can be destroyed correctly, but the memory it uses may be freed later.

    Please find the attached project that contains a memory leak test for the window control which it successfully passes with the LIB dlls and unfortunately fails with the Q2 2011 dlls.

    Hope this helps.

    Greetings,
    Miroslav Nedyalkov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  12. Raphael
    Raphael avatar
    15 posts
    Member since:
    Jan 2011

    Posted 04 Aug 2011 Link to this post

    Thank you for your sample and for your quick answer.

    I just modified a little your OpenWindow method to have more efficient result : I replace the simple content you put with a radtreeview :

    private void OnOpenWindow(object sender, RoutedEventArgs e)
            {
                RadTreeView tv = new RadTreeView();
                RadTreeViewItem tvi = new RadTreeViewItem { Header = "Test", IsExpanded = true };
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
     
                tv.Items.Add(tvi);
     
                tvi = new RadTreeViewItem { Header = "Test", IsExpanded = true };
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
                tvi.Items.Add(new RadTreeViewItem { Header = "Test" });
     
                tv.Items.Add(tvi);
                 
                var window = new RadWindow
                {
                    Content = tv, WindowState = WindowState.Maximized
                };
                windowReference = new WeakReference(window);
                window.ShowDialog();
            }

    And then, I test and take care of the memory used :
    1. Launch the project : 22Mb (Mem1.JPG)
    2. clic on the open window button, the window opens : 39Mb (Mem2.JPG)
    3. Close the window and force GC to free memory thanks to many clics on the button and after check that window is really destroyed : 38Mb (Mem3.JPG)

     

    When i repeat the scenario, the memory increases more slowly (about 5Mb) but not frees as much as it takes ...
    Maybe the problem comes from the treeview or content inside ?? Do you have an idea about that ?

    Thanks for your help.

    Raphael

  13. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 04 Aug 2011 Link to this post

    Hello Raphael,

     As I previously mentioned the memory usage is not a correct way to test are the objects destroyed or not as the occupied memory depends on the CLR and the GC. There are various optimizations which may cause not freeing the memory immediately. For more information about how the GC works and how to track down memory problems you may refer to this article and this article.

    All the best,
    Miroslav Nedyalkov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  14. Jason
    Jason avatar
    30 posts
    Member since:
    May 2009

    Posted 26 Oct 2011 Link to this post

    Hi, is this fixed in the Q2 2011 SP1 build?  We are unfortunately unable to use that version due to a bug that was introduced into the RadGrid but it would be good to know that when we can upgrade this sizechanged memory leak will have been fixed
  15. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 27 Oct 2011 Link to this post

    Hi Jason,

    The known memory leak related to the SizeChanged event of the RootVisual was fixed and there is no known memory leaks in the RadWindow control in the current version of RadControls for Silverlight.

    Regards,
    Miroslav Nedyalkov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top
DevCraft banner