destructors, how?

Jason Dufair squeak-dev at lists.squeakfoundation.org
Tue Oct 22 16:14:36 UTC 2002


You could consider a manual garbage collection to free up those 
resources.  I'm not a GC guru, so I can't guarantee it will do what you 
want, but I'd give it a try.  I believe the method is on ObjectMemory 
somwhere.

Ragnar Hojland Espinosa wrote:

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

-- 
Jason Dufair - jase at dufair.org
http://www.dufair.org/
"Being in politics is like being a football coach.
You have to be smart enough to understand the game,
and dumb enough to think it's important."
-- Eugene McCarthy





More information about the Squeak-dev mailing list