On 28 jun 2009, at 10.34, Thomas Davie wrote:

Again, IDisposable in C# has nothing to do with early
destruction/deallocation of the object. It's purpose to is perform
explicit cleanup of external resources, resources not managed by the
GC system. For example: file handles, sockets, OS system handles, etc.
Calling Dispose() on a C# system does not mark the object for early
collection (AFAIK).

Oh, personally I would just let GC deal with that -- tie a handle under GC to them, add a finalizer on the handle, and destroy the reference when the handle is destroyed by the GC system.


That is not always a valid approach though. If you work with a lot of scarce resources in a short period of time, you might run out of them by outpacing the GC, taking down your app, and possibly the whole system. In general, but in cases such as these in particular, I think it's best to separate memory management from the management of other scarce resources. Some sort of invalidation pattern seems to be the best solution that we know of right now for achieving this. It's great that the GC allows us to not have to deal with the intricate details of managing memory, but I don't think that means that we're off the hook when it comes to thinking about object ownership, and the management of our object graphs.

j o a r


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to