This is a migrated thread and some comments may be shown as answers.

Q1 2011 WinForms Memory Leak

6 Answers 295 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ivan
Top achievements
Rank 1
Ivan asked on 09 Jun 2011, 04:00 PM
Hello,

We purchased the licenses for Telerik WinForms components and having memory leaks. I've already read similar threads (performance considerations, increasing execution speed of Telerik assemblies), but it didn't solve my problem. Other then that, we verified the code against the following rules which are best coding practices that DEV teams must follow:
— objects that implements IDisposable must be disposed;
— grids must be wrapped with BeginUpdate & EndUpdate methods whenever they are getting changed (same holds true for RadTreeView);
— no excessive database connections;
— database connections are wrapped with C# "using" operator;
— time-consuming operations moved to background processes, which writes Trace/Debug messages when finished;
— custom themes are built in separate DLL and initialized in new thread which gets closed, when job is done.

The app itself represents MDI container with RadDock on it (Dock = Fill). All MDI child forms are opened in RadDock's new tab. The default tab is Desktop with a grid and 2 more Tool Windows: Tree View which is used as collapsible menu and Recent Activity at the bottom (in fact, similar control layout as VS2010 or SQL Management Studio). We are using custom Telerik themes, which are compiled into separate DLLs to gain the best performance and they are loaded in background worker process when the app starts.

Steps to reproduce (see attachments 1-5, in order they presented)
1. Starting the app (MDI container)
2. Choosing User List (form with single grid) from Tree View aka menu
3. User List View is loaded
4. Closing User List View
5. PROBLEM: Nevertheless form is disposed and it's not in the RadDock tool/window collection — consumed memory amount remained the same. Looping iterations from 2 to 4, will lead to memory leak (memory amount constantly grows)!

In addition to that, I would like to point that we're using MVP in WinForms. Base Form and UserControl classes are always disposing inner objects or in terms of MVP — presenters, when Form is getting closed. Here's the Trace log:
..
UserListView is initialized.
UserListView is loaded.
The thread '<No Name>' (0x2304) has exited with code 0 (0x0).
UserListView is disposed.
..

Finally, in attachment there's a screen from ANTS Memory Profiler. 


Please advice, how we could solve this problem? We spent some time before writing to support, so please be patient with my insistence.


Kind regards,
Ivan


6 Answers, 1 is accepted

Sort by
0
Ivan
Top achievements
Rank 1
answered on 14 Jun 2011, 01:38 PM
Guys, can anyone get back to me please?
0
Jack
Telerik team
answered on 15 Jun 2011, 07:55 AM
Hello Ivan,

Thank you for contacting us.

I can confirm that there was a memory leak in our latest release. We have already addressed it and the fix will be available in our next release - Q2 2011 in July. If this is a show stopper for you, we can prepare an internal build where the issue will be addressed. 

It is also possible that you have faced another issue and we want to investigate the case further. Could you please send us your application? This will help us to identify the issue and find a proper solution faster. Please note that you have to open a new support ticket in order to be able to attach your files.

Thank you for your cooperation.

A bit off topic, in your case you need a quick response from us, please directly open a new support tickets. Support tickets are reviewed and handled according to the license that you have.

I am looking forward to your reply.
 
Greetings,
Jack
the Telerik team
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
0
Khizar Khan
Top achievements
Rank 1
answered on 07 Aug 2011, 01:33 PM
Hi,

We are using custome theme and there is a very big foot print when our app runs and there is a memory leak as well..
can you please advice how to do the following as suggested in this thread.
"custom themes are built in separate DLL and initialized in new thread which gets closed, when job is done."
this will definitely help. thanks.

khizar
0
Peter
Telerik team
answered on 10 Aug 2011, 04:01 PM
Hi Khizar Khan,

We assume that Ivan refers to this KB Article: http://www.telerik.com/support/kb/winforms/themes/load-theme-components-in-a-separate-thread.aspx

Hope you find this useful. Let us know if you have further questions.

Best wishes,
Peter
the Telerik team

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

0
asimptota
Top achievements
Rank 1
answered on 05 Mar 2012, 09:52 PM
Hello,
I am experiencing the same problem as Ivan and I'm using Q3 2011. I've modified Dispose method on every form like this:
protected override void Dispose(bool disposing)
{
    if (disposing && (components != null))
    {
        foreach (RadControl ctrl in this.Controls)
        {
            ctrl.Dispose();
        }
        components.Dispose();
    }
    base.Dispose(disposing);
}
and got a slightly less memory leak. ANTS says that RadPropertyValue is increasing and I've noticed that some GDI objects (up to 2) survive each form Dispose. Could you please tell me how to get rid of this leak?
0
Peter
Telerik team
answered on 08 Mar 2012, 04:11 PM
Hello asimptota,

Thank you for writing.

Could you please provide me with a sample project demonstrating this behavior and also exact steps that I need to follow in order to reproduce it on my end?

Please note that when testing for memory leaks you should call the garbage collector before checking the memory. 

GC.Collect();
GC.WaitForPendingFinalizers();
GC.WaitForFullGCApproach();
GC.WaitForFullGCComplete();
GC.Collect();

This is necessary because .NET garbage collector is non-deterministic and you cannot say for sure when and how memory will be released. 

Regarding the large amount of RadPropertyValue - these are used by our themes, which are static resources and they are loaded only once. When loaded, themes stay in memory until the application is closed.

The DOM element structure of RadControl is a complex tree with a lot of objects. Some of the objects cannot be released with a single garbage collection request, sometimes they become second or third generation objects. Find more about generations in this article

Regards,
Peter
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
General Discussions
Asked by
Ivan
Top achievements
Rank 1
Answers by
Ivan
Top achievements
Rank 1
Jack
Telerik team
Khizar Khan
Top achievements
Rank 1
Peter
Telerik team
asimptota
Top achievements
Rank 1
Share this question
or