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

Memory issues with radform, can't seem to dispose added controls

1 Answer 119 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Aron
Top achievements
Rank 1
Aron asked on 13 May 2015, 07:17 AM

Hello!

 What's the proper way to dispose of a radform to ensure that all of the added controls also gets removed? As it is now, each time i start the form and then close it, memory consumption goes up with about 10mb. The core issue here seems to be that even though the form calls .Dispose() when it's closed the controls added to the form does not get cleared. I've tried setting all of the controls in the form to null on close, but this did not have any effect on the memory issue. 

 To make sure that it was an issue with the specific form, i created an empty form and instead opened that one, and when that form closed, memory did not increase, which leads me to be pretty sure that it has something to do with the controls added to the form not getting disposed. 

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 13 May 2015, 02:00 PM
Hello Aron,

Thank you for writing.

Generally the garbage collector is nondeterministic and you cannot tell for sure when the will be executed. This means that even if the form is disposed correctly the memory would not be released right after the form is closed. By default you do not need to dispose the form or the controls manually (unless you are using modal dialog) and the memory will be freed at some point. You can test this properly with a memory profiler tool (JustTrace for example). With this tool you can force the garbage collector and properly determine, if indeed there is a memory leak. More information is available here: Things to keep in mind when inspecting your application's memory usage. 

In addition you should make sure that there is no references to the form or the controls in it in your code. Even a single reference can prevent the entire form from proper disposal.

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

Regards,
Dimitar
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
Tags
General Discussions
Asked by
Aron
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or