[gclist] Finalizer flame wars.

Fergus Henderson fjh@cs.mu.OZ.AU
Sat, 11 May 1996 01:29:17 +1000 (EST)


Robert A Duff wrote:
> 
> I must admit, however, that when the resource in question is fairly
> limited or fairly expensive (like the file handle case), using a
> finalizer that gets run who-knows-when is a questionable practise.  We
> might have millions or billions of memory cells, but we probably only
> have hundreds or thousands of file handles.

As has been pointed previously out on this list, if the allocator for
the resource invokes garbage collection on resource exhaustion, then
you don't have to worry about running out prematurely, even if the
resource is a very limited one such as file handles.

(Well, technically if you have a conservative garbage collector
rather than an accurate one, you might have to worry just a little
bit.  But I think this approach would work well in practice even with
a conservative collector.)

-- 
Fergus Henderson <fjh@cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3         |     -- the last words of T. S. Garp.