Project

General

Profile

Bug #22251

Updated by Eregon (Benoit Daloze) about 1 month ago

``` 
 $ ruby -e 'GC.disable; m 'm = ObjectSpace::WeakMap.new; Thread.new { m[Object.new] = Object.new }.join; GC.start; p m.size; p m.keys; p m.size'  
 
 1 
 [] 
 0 
 ``` 

 The first line is 1 but I would expect 0. 
 Interestingly calling `#keys` seems to force an update. 

 If I GC twice then it seems correct: 
 ``` 
 $ ruby -e 'GC.disable; m 'm = ObjectSpace::WeakMap.new; Thread.new { m[Object.new] = Object.new }.join; GC.start; GC.start; p m.size; p m.keys; p m.size'  
 
 0 
 [] 
 0 
 ``` 

 Could we decrease size whenever we "remove" an entry? 

 Apologies if that's already known, I searched for an existing issue for this but didn't find anything.

Back