Memory Leak in RadPageView

1 Answer 312 Views
General Discussions PageView
mohamed
Top achievements
Rank 1
mohamed asked on 05 Oct 2021, 03:01 PM | edited on 05 Oct 2021, 03:03 PM

Hi,

Memory leakage issue found while disposing form that added in RadPageView Control.  But the memory not decresed even I disposed form and RadPageViewPage object. Please Help. I am attaching sample project and demo video with question.

Following are the code samples

Adding from to PageView

            frmSales frm = new frmSales();
            frm.Dock = DockStyle.Fill;
            frm.TopLevel = false;
            frm.TopMost = true;
            frm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            var page = new RadPageViewPage();
            page.Controls.Add(frm);
            radPageView1.Pages.Add(page);
            radPageView1.SelectedPage = page;
            frm.Show();

 

Removing Form from PageView

 RadPageViewPage page = radPageView1.Pages[radPageView1.Pages.Count - 1];
                    RadForm frm = (RadForm)page.Controls[0];
                    frmSales obj = (frmSales)frm;
                    radPageView1.Pages.Remove(page);
                    page.Dispose();
                    page = null;
                    obj.ClearMem2();
                    obj.Close();
                    obj.Dispose();
                    obj = null;
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                    GC.Collect();

Any help will be very appreciated. Thanks  in advance

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 08 Oct 2021, 11:16 AM

Hi,

Thank you for the attached project.

I have examined it and especially the problematic frmSales form, by debugging the source code to see where the problem might come from. After several hours of debugging, I can confirm there is a memory leak. But the memory leak comes from the controls and components serialized in the frmSales.Designer.cs. There are more than 250 controls in total that do not have parent control. When frmSales is disposed and all controls from the Controls collection are removed recursively, these more than 250 controls will remain in the memory. The problem is in this specific form, not in Telerik UI for WinForms controls.

If you remove all visible controls from the form you can see that a large list with controls is still available:

And when you open the frmSales.Designer.cs you can see that it has almost 6000 lines of code and 262 controls.

These controls need to be removed from the form or manually disposed in order to free the memory. The garbage collector cannot collect them, because they have a reference to the frmSales.

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Todor Vyagov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
General Discussions PageView
Asked by
mohamed
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or