Hi, I am use WeakKeyDict for manage memory for parallel implementations.
I found it does not work properly the object created and assigned locally in a function.
Below is an example.
The results of main function and the code below it should be the same.
But, WeakKeyDict in the main function does not clean objects that do not have a variable pointing themselves.
And one more problem is that WeakKeyDict cleans garbage data only if gc
called twice.
type Constructor
id::Int
end
d = WeakKeyDict()
function main()
global d
a = Constructor(1)
d[a] = a.id
a = 0
gc()
gc()
println(d)
end
main()
a = Constructor(1)
d[a] = a.id
a = 0
gc()
gc() # if gc once does not remove...
println(d)