Re: NSDocument reference held by NSSavePanel?
Re: NSDocument reference held by NSSavePanel?
- Subject: Re: NSDocument reference held by NSSavePanel?
- From: Quincey Morris <email@hidden>
- Date: Mon, 13 Apr 2009 17:14:22 -0700
On Apr 13, 2009, at 13:56, David Scheidt wrote:
In general, though, it's perfectly reasonable to put off garbage
collection for as long as possible. It's fairly expensive, and if
there is no pressure on the resource being garbage-collected, it's
perfectly reasonable to defer garbage collection until there is
pressure. There's a reasonable chance that the application will
terminate before then, and then you've save the effort. In other
words, it's not the clock that controls whether garbage collection
need to run, it's the presence of garbage.
This is a perfectly reasonably argument, and perhaps it's the only
argument. But I wasn't suggesting earlier that a garbage collector
which doesn't collect as soon as possible (or nearly so) is defective,
but that a garbage collector which defers some collections
indefinitely implies that the finalize method is useless. (Or,
equivalently, that if you want to use finalize, such a garbage
collector is defective.)
My reasoning is that finalize is used to manage non-GC resources, not
GC memory objects. With an indefinitely deferring collector, where you
can't expect finalize to be called "soon", then you've already lost
the game in terms of non-GC resource management (because non-GC
resources don't exert any pressure on the collector), and you may as
well abandon your finalize-based management strategy.
One caveat: if a GC-object manages a *root* reference to another GC-
object (for example, object A maintains a reference to object B in a
global variable), then finalize would be a suitable place to manage
the root reference, even if it is deferred.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden