Destructor has only one task that is to release all the resources owned by this class. The resource could be memory (including shared memory), opened files, network connections, etc. The key is that if the class is the owner of the resources the destructor has to release them otherwise it could cause problem in your process (if the OS handle resource release when a process dies) or the whole machine (if the OS does not release resource when a process dies).