Monday, April 11, 2005

[.NET] Dispose, Finalization, and Resource Management

Garbage collection is not perfect when you would like to have an explicit control over used resources.

Many people who hear about the Dispose pattern for the first time complain that the GC isn’t doing its job. They think it should collect resources, and that this is just like having to manage resources as you did in the unmanaged world. The truth is that the GC was never meant to manage resources. It was designed to manage memory and it is excellent in doing just that.
The only problem is that automatic management of memory and objects makes it difficult to ensure that resources held by objects are released deterministically (that is, early).

0 Comments:

Post a Comment

<< Home