Mantis - Squeak
Viewing Issue Advanced Details
7350 Collections minor always 05-06-09 22:08 02-06-11 23:48
nicolas cellier  
leves  
normal  
closed 3.10.2  
fixed  
none    
none trunk  
0007350: WeakSet tend to grow because they don't recycle nil slots
When objects are reclaimed, they are replaced with nil in the WeakSet array.
However, due to implementation of #scanFor: these nilled-slots are never reused until the next WeakSet #grow.

Adrian Lienhard reported a nice example at
http://permalink.gmane.org/gmane.comp.lang.smalltalk.squeak.general/133778 [^]
Beware, nil slot cannot be recycled without taking care of possible collisions as developped in the squeak-dev thread above.

We must first take care to #fixCollisionsFrom: nilIndex.

Please find a fix attempt below. To be tested extensively!
 M7350-WeakSet-recycleNilSlots-nice.1.cs [^] (2,011 bytes) 05-06-09 22:10
 M7350-WeakSet-recycleNilSlots-nice.2.cs [^] (2,540 bytes) 05-06-09 23:43
 M7350-WeakSet-tests-nice.1.cs [^] (5,076 bytes) 05-06-09 23:44

Notes
(0013120)
nicolas cellier   
05-06-09 23:44   
Sorry, M7350-WeakSet-recycleNilSlots-nice.1.cs was bugged !
Try M7350-WeakSet-recycleNilSlots-nice.2.cs instead
(0013122)
nicolas cellier   
05-07-09 10:05   
"fix begin"
Installer mantis bug: 7350 fix: 'M7350-WeakSet-recycleNilSlots-nice.2.cs'.
"fix test"
Installer mantis bug: 7350 fix: 'M7350-WeakSet-tests-nice.1.cs'.
"fix end"
(0013907)
leves   
11-07-10 02:19   
The problem was solved in Squeak 4.1 in a different way. Slots are reclaimed during growing and removal. I integrated the tests to the Trunk.