PDA

View Full Version : What is the best way and place to deallocate the memory?



alizadeh91
16th March 2012, 08:56
What is the best way and best place to deallocate memory in Qt? Is the destructor is a good choice to deallocate the memory?
Thanks

high_flyer
16th March 2012, 09:19
What is the best way and best place to deallocate memory in Qt?
Not only in Qt - but in general:
When the allocated memory is no longer needed.

s the destructor is a good choice to deallocate the memory?
The destructor is the LAST place/time at which an object can free the momory it allocated.
But you should not wait that long if any given chunk of memory is not needed any more - you should free any memory as soon as you can.