Code Issues – Redundant Destructor
Destructors are invoked automatically, and used to destroy instances of classes. The developer has no control over when the destructor is called, because this is determined by the garbage collector. Redundant destructor is a an empty destructor without any code inside, that can be safely removed.
Empty destructors should not be used at all. If a class contains a destructor, an entry is created in the “Finalize queue”, controlled by the garbage collector. When the destructor is called, the garbage collector is invoked to process the queue. If the destructor is empty, this just causes a needless loss of performance.
How to fix:
- Apply the Remove Redundant Destructor refactoring:
—– Products: CodeRush Pro Versions: 12.1 and up VS IDEs: any Updated: Nov/12/2012 ID: C068