Describe the lifecycle of an object implementing IDisposable and how to avoid memory leaks with unmanaged resources.