Rule Definition
Because the cleanup code executed at dispose-time is a superset of the code executed at the finalize-time, there is no need to call the finalize-time code during object finalization after the object has been disposed. Moreover, keeping objects that don't need to be finalized in the finalization queue has a cost associated with it. This is why the Dispose() method should call GC.SuppressFinalize, which removes the object from the finalization queue and thus prevents unnecessary finalization.
Remediation
If the method is an implementation of Dispose, add a call to System.GC.SuppressFinalize. If the method is not an implementation of Dispose, either remove the call to System.GC.SuppressFinalize or move it to the type's Dispose implementation. Change all calls to System.GC.SuppressFinalize to pass this (Me in Visual Basic).
Violation Code Sample
public void Dispose() {
}
Fixed Code Sample
public void Dispose(){
Dispose(true);
GC.SupressFinalize(this);
}
Reference
Resource Management in .NET
by Krzysztof Cwalina
Program Manager - Microsoft .NET Framework
http://www.gotdotnet.com/team/libraries/whitepapers/resourcemanagement/resourcemanagement.aspx
Related Technologies
.Net
Technical Criterion
Efficiency - Memory, Network and Disk Space Management
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.