destructors, how?

Peter Crowther Peter.Crowther at networkinference.com
Tue Oct 22 16:20:57 UTC 2002


> From: Ragnar Hojland Espinosa [mailto:ragnar at linalco.com] 
> Does finalize get called 
> right away, or only when squeak does the GC?

Only when a suitable GC is performed.  Incremental GCs are performed
pretty regularly and will catch most of the newly-created trash; full
GCs that will find all the trash are much, much rarer.

> And if so, am I 
> guaranteed that it'll be GCed that moment?

It will be GCed at the point the GC runs.  It could be some time
(milliseconds to seconds) before the finalizer thread catches up and
tells you.

As Jason points out, you can force GC (try 'Smalltalk garbageCollect'
IIRC).

> 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.

Eh?  If you're pooling, you need some kind of pool manager anyway ---
which will undoubtedly hold references to all connections and know when
connections should be closed.  Do you have some kind of magic here that
I don't understand (very likely!) - if so, please explain how you can do
pooling without a pool manager, because I want to nick the idea and use
it :-).

		- Peter



More information about the Squeak-dev mailing list