Should “Dispose” only be used for types containing unmanaged resources?

There are different valid uses for IDisposable. A simple example is holding an open file, which you need to be closed at certain moment, as soon as you don’t need it any more. Of course, you could provide a method Close, but having it in Dispose and using pattern like using (var f = new … Read more

is memory leak? why java.lang.ref.Finalizer eat so much memory

Some classes implement the Object.finalize() method. Objects which override this method need to called by a background thread call finalizer, and they can’t be cleaned up until this happens. If these tasks are short and you don’t discard many of these it all works well. However if you are creating lots of these objects and/or … Read more

Use of Finalize/Dispose method in C#

The recommended IDisposable pattern is here. When programming a class that uses IDisposable, generally you should use two patterns: When implementing a sealed class that doesn’t use unmanaged resources, you simply implement a Dispose method as with normal interface implementations: public sealed class A : IDisposable { public void Dispose() { // get rid of … Read more

tech