JuliaIO / JLD.jl

Saving and loading julia variables while preserving native types
MIT License
277 stars 55 forks source link

delete! doesn't delete references #258

Open carstenbauer opened 5 years ago

carstenbauer commented 5 years ago

MWE:

julia> using JLD

julia> x = [rand(2,2) for _ in 1:100];

julia> @save "test.jld" x

julia> jldopen("test.jld", "r+") do f
           delete!(f, "x")
       end
false

julia> jldopen("test.jld", "r") do f
           names(f["_refs"])
       end
100-element Array{String,1}:
 "00000001"
 "00000002"
 "00000003"
 "00000004"
 "00000005"
 "00000006"
 "00000007"
 "00000008"
 "00000009"
 "00000010"
 "00000011"
 "00000012"
 ⋮
 "00000090"
 "00000091"
 "00000092"
 "00000093"
 "00000094"
 "00000095"
 "00000096"
 "00000097"
 "00000098"
 "00000099"
 "00000100"

Looking at https://github.com/JuliaIO/JLD.jl/blob/master/src/JLD.jl#L311 it's obvious why the references haven't been deleted. The references simply aren't in refspath = "/_refs/x".