WeakKeyIdDicts
Implements a WeakKeyIdDict which constructs a hash table where the keys are weak references to objects that may be garbage collected even when referenced in a hash table.
It defines one type, WeakKeyIdDict
, that follows the same API as Dict
.
_tmp_key = [1]
wkd = WeakKeyIdDict(_tmp_key => 1)
let tmp = [42]
wkd[tmp] = 2
@show length(wkd) # 2
end
# at this point there is no strong reference left to the vector [42]
# previously reachable via tmp
GC.gc(true)
@show length(wkd) # 1