You never should call destructor functions using the ~<destructor>
function directly! You should just call
delete alg;
or rely on the destructor being called and allocated memory being released from going out of scope with a stack allocated instance of your class.
The direct call of the destructor function has no influence on the memory management at all, and is wrong in most cases (there are rare necessary with custom delete
implementations).
This will free the memory allocated before.
Though you might see data structures remaining there. Accessing these after delete
, leads to undefined behavior in any case!