destructors, how?

Ragnar Hojland Espinosa ragnar at linalco.com
Tue Oct 22 16:11:41 UTC 2002


On Tue, Oct 22, 2002 at 03:55:39PM +0100, Peter Crowther wrote:
> > I can't find out how to write a destructor 
> > or something functionally equivalent.
> 
> Check out implementors of 'finalize' (IIRC).  In essence, you hold onto
> the object using a weak array; are notified when it is
> garbage-collected; and clear appropriate fields based on copies of the
> data in the object.

Finalize did get some nice matches.  Does finalize get called right away, or
only when squeak does the GC?  And if so, am I guaranteed that it'll be GCed
that moment?

The thing is.. I'm leaving behind lots open postgres connections which would
be nicely closed with a "destructor", and right now I don't know how to
automatically close (maybe you cant?) when it should (the sooner the
better). Obviously, postgres complains quite loudly when you have too many
open, and things suddely get very ugly.

Ah well.. at least I can add the closes by hand :/  but that means leaks
and sort of rules out to have decent db connection pools in any way I can
think of.. so I must be missing something.
-- 
Ragnar Hojland - Project Manager
Linalco "Especialistas Linux y en Software Libre"
Tel: +34-91-5970074 Fax: +34-91-5970083



More information about the Squeak-dev mailing list