c# - How to Clear() controls without causing a memory leak -


after reading control.clear(); causing memory leaks (verified @ msdn), wondering if:

while (controls.count > 0) controls[0].dispose(); 

will enough, or have iterate recursively through controls within controls?

also, there reason control.clear(); after that? (as saw saying somewhere)?

thanks.

the posted snippet correct. no clear() required, control.dispose() method removes control controls collection. why works.

the less alarming version of loop is:

 (int ix = controls.count-1; ix >= 0; --ix) controls[ix].dispose(); 

no need iterate through children of control , dispose them, happens automatically.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -