>>>>Hi, >>>>I initialize object to private vairable via >>>> >>>>public class MyBase >>>>{ >>>>private MyClass _myClass = new MyClass(); >>>>} >>>> >>>>I found that it caused memory leak as it is not released. May I know how should I release it once myBase is released? >>>> >>>>Thank you >>> >>>Take a look at these references >>> >>>http://www.bluebytesoftware.com/blog/PermaLink.aspx?guid=88e62cdf-5919-4ac7-bc33-20c06ae539ae >>>http://lyontamers.com/blogs/jimlyon/archive/2008/08/29/garbage-collection-finalizers-and-dispose-what-every-c-programmer-should-know.aspx >> >>Thank you for the links. I sort of did have the impression that the .NET garbage collector takes care of things for me and I only need to implement Dispose() for expensive resources. I think I know better now. > >I am working through this myself. FXCop recommends implementing IDisposable for my classes that have class fields which are assigned objects that implement IDisposable.
That's exactly what Troelsen says. He says if the class creator specified an IDisposable interface, you are meant to implement it.