Considering the following:
tbModelHFrame = new TbModelHeaderFrame(this, storage->getDataBase());
I guess the correct way to delete tbModelHFrame memory will be
delete tbModelHFrame;
Right?
How do I check that the memory was really released?
How do I check that the memory was really released?
You don't.
C++ has no means of telling whether a pointer points to a valid object or a random region in memory. The latter includes a region that was valid at some point, but has been deleted since.
It is up to the developer to organize their code in a way that this cannot happen.
The only guarantee that the language gives you to help you out here, is that a delete call never fails. So if you call delete once on the object, you can be reasonably sure that the object destroyed properly and the memory was released. Just don't attempt to access it again afterwards, or you'll be in trouble.
Yes, what is allocated with new should be freed with delete.
A way to check if every dinamically allocated memory has been freed is to use Valgrind's Memcheck
Anyway, it is usually safer to use smart pointers (See here).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With