Freeing of memory used by controls

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

Freeing of memory used by controls

Post by deepti »

Hi,

There is a dialog I've created which has all controls created using "new". I have read that just calling "Destroy()" when the dialog is closed is sufficient. And wxWidgets internally frees up memory taken up by all controls. Could you please confirm that this is the case?

Thank you!
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Freeing of memory used by controls

Post by doublemax »

Any wxWindow (this includes wxFrame, wxDialog etc) destroys all its children and its sizer when getting destroyed. As this happens recursively, you usually don't have to destroy any controls created with new.

There are a few exceptions though, but these are mentioned in the documentation for the respective class.
Use the source, Luke!
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

Re: Freeing of memory used by controls

Post by deepti »

Thank you for the reply!!!
Post Reply