Protected virtual method that frees memory.
This method can be overridden in derived classes to implement custom memory deallocation.