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
Printable View
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
Not only in Qt - but in general:Quote:
What is the best way and best place to deallocate memory in Qt?
When the allocated memory is no longer needed.
The destructor is the LAST place/time at which an object can free the momory it allocated.Quote:
s the destructor is a good choice to deallocate the memory?
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.