ReSharper 2017.2 Help

Code Inspection: EmptyDestructor

An empty destructor does not contain any special actions that must be completed before the object is reclaimed by the garbage collector. Such a destructor adds nothing to what the garbage collector will do automatically, it only causes overhead.

In C#, destructors are used instead of overrides of the Finalize method to provide finalizers for your classes. If a class has a destructor, the garbage collector marks the corresponding objects for finalization: for each object it adds an entry to the so called finalization queue. At destructor invocation, the garbage collector is invoked — it analyses the finalization queue and runs a finalizer. If a destructor is empty, the finalizer does not contain any user-defined instructions, so all operations with the finalization queue and finalizers are unnecessary and only consume resources.

ReSharper suggests removing an empty destructor to improve both readability and performance of your code.

Last modified: 20 October 2017

See Also