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 » Wed Aug 15, 2018 10:23 am

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: 14638
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Freeing of memory used by controls

Post by doublemax » Wed Aug 15, 2018 10:28 am

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 » Wed Aug 15, 2018 11:03 am

Thank you for the reply!!!

Post Reply