Removes this object, enough? or do i need to do more?

I have this code: -

using (System.Security.Cryptography.SHA256 sha2 = new System.Security.Cryptography.SHA256Managed()) { .. } 

Do I need to put this line of code only before I leave this selection area ... or have I already placed the "call".

 sha2.Clear(); 
+1
source share
5 answers

Because the AFAIK Clear () method simply calls Dispose, the use block should be sufficient to ensure that resources are freed.

+3
source

IMHO, if you call Dispose () is not enough to delete the object, or there is a serious error in the code or a serious design flaw. So don't worry about taking any extra steps in your own code!

+1
source

If you look at Reflector, you will see that Clear just calls Dispose , so there is no need to call Clear in your example.

Many of the infrastructure classes offer Close / Clear / Whatever Dispose wrapper is made a little simpler.

+1
source

And a general useful hint - do not forget that the source for all this material is available these days - it often helps me answer this question without thinking or making a conclusion.

This is a good place to start: http://www.codeplex.com/NetMassDownloader

0
source

Dispose () is good enough.

I am not sure how .NET works. But calling an extra function or "set null" will degrade Java performance.

The CLR / Java VM (and should) is able to clear all dereferenced managed objects from the "roots" in the next garbage collection.

PS. Dispose () cleans up "unmanaged" resources to improve GC performance, as it does not wait for the Finallizer stream to complete.

-2
source

All Articles