>>finalize questions

Michael van der Gulik squeakml at gulik.co.nz
Sun Aug 20 05:48:08 UTC 2006


Hi all.

Two questions for today.

---------
1. What does Object>>finalize do?

It appears not to do much at all. I had a quick poke at the VM source 
(but not enough to grok what's happening). It appears to only be used 
for weak references or something?

I made a test class (Dunce) and implemented:

finalize
     Transcript show: 'finalize called..'.

but the Transcript remains blank even lots of "Dunce new" and then 
"Dunce instanceCount" (returns 1).

Also, "w := WeakArray with: (Dunce new)" doesn't call finalize either...

-----------
2. I have an object with a process "in" it. How can I make sure that 
process is terminated when there are no more references to that object?

I assume processes are automagically added to the garbage collector's 
root pointer collection, preventing that object from being garbage 
collected.

i.e.:

Dunce>>aProcess
	[ [ self doSomeCleanUpAndWait5Seconds ] repeat ]
		forkNamed: 'Silly process'.

Michael vdG.




More information about the Squeak-dev mailing list