Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set list items to null C#?

I have a user control called container in which I am adding other user controls at run time.

I want to remove all controls from container, I am doing container.Controls.Clear() but my controls are still in memory, how can I make them null ?

like image 727
Embedd_0913 Avatar asked Dec 12 '22 02:12

Embedd_0913


1 Answers

Calling the Clear method does not remove control handles from memory. You must explicitly call the Dispose method to avoid memory leaks.

read more: http://msdn.microsoft.com/en-us/library/system.windows.forms.control.controlcollection.clear.aspx

like image 80
ericosg Avatar answered Dec 14 '22 15:12

ericosg