Skip to content

Gendarme.Rules.Performance.RemoveUnneededFinalizerRule(git)

Sebastien Pouliot edited this page Mar 2, 2011 · 1 revision

RemoveUnneededFinalizerRule

Assembly: Gendarme.Rules.Performance
Version: git

Description

This rule looks for types that have an empty finalizer (a.k.a. destructor in C# or Finalize method). Finalizers that simply set fields to null are considered to be empty because this does not help the garbage collection. You should remove the empty finalizer to alleviate pressure on the garbage collector and finalizer thread.

Examples

Bad example (empty):

class Bad {
    ~Bad ()
    {
    }
}

Bad example (only nulls fields):

class Bad {
    object o;
    ~Bad ()
    {
        o = null;
    }
}

Good example:

class Good {
    object o;
}

Notes

  • Prior to Gendarme 2.2 this rule was named EmptyDestructorRule

Source code

You can browse the latest source code of this rule on github.com

Clone this wiki locally