[BUG][FIX] WeakGCFix-wbk

Bryce Kampjes bryce at kampjes.demon.co.uk
Mon Mar 22 19:44:28 UTC 2004


Hello

Andreas Raab writes:
 > Hi,
 > 
 > > Weak references can leave dangling pointers if the weak
 > > object is in old space and it points to a new space object.
 > 
 > Your observation troubles me greatly. This should not happen, and as far as
 > I know it cannot happen. Do you have a reproducable example?


Try:

weakRef := WeakValueAssociation new.
Smalltalk garbageCollect. "make it old"
TestClass gcTest: weakRef
Smalltalk garbageCollectMost. "incr. GC"
weakRef value. "and it's now gone"

TestClass class>>gcTest: weakRef
	weakRef value: Object new.

By moving the new object creation out into it's own method
we remove the risk of it getting captured but the context
object.

Bryce



More information about the Squeak-dev mailing list