Obvious when you point it out =o) Thanks.
On Aug 2, 2004, at 11:26 PM, Andreas Raab wrote:
The literal string is part of the compiled method. Try:
weakDict at: 2 put: 's2' copy
instead. The same is true for other literals.
Cheers,
- Andreas
----- Original Message ----- From: "Brian Murphy-Dye" brian.murphydye@mac.com To: "The general-purpose Squeak developers list" squeak-dev@lists.squeakfoundation.org Sent: Monday, August 02, 2004 7:57 PM Subject: WeakValueDictionary
When executing the code below, I expected both values to be garbage collected, yet 's2' apparently isn't. Other attempts were using 'Smalltalk garbageCollect' and adding 's2' from another method (to make sure the block context wasn't preventing garbage collection). Any ideas?
| weakDict | weakDict := WeakValueDictionary new. weakDict at: 1 put: Object new. weakDict at: 2 put: 's2'. Smalltalk garbageCollectMost. (weakDict at: 1) = nil ifFalse: ['at 1 not nil' inspect]. (weakDict at: 2) = nil ifFalse: ['at 2 not nil' inspect]. "=> shows an inspector"
Thanks, Brian.