using Mmap
fname = tempname()
write(fname, "bar")
function reading()
io = open(fname)
mm = Mmap.mmap(io)
q = view(mm, 1:2)
close(io)
end
reading()
isfile(fname) && rm(fname)
gives
ERROR: LoadError: IOError: unlink("C:\\Users\\nzimm\\AppData\\Local\\Temp\\jl_g1GveD8R03"): permission denied (EACCES)
Stacktrace:
[1] uv_error
@ .\libuv.jl:106 [inlined]
[2] unlink(p::String)
[1] uv_error
@ .\libuv.jl:106 [inlined]
[2] unlink(p::String)
@ .\libuv.jl:106 [inlined]
[2] unlink(p::String)
[2] unlink(p::String)
@ Base.Filesystem .\file.jl:1105
[3] rm(path::String; force::Bool, recursive::Bool)
@ Base.Filesystem .\file.jl:283
[4] rm(path::String)
@ Base.Filesystem .\file.jl:273
[5] top-level scope
@ C:\Users\nzimm\github\ZipArchives.jl\mmap.jl:16
in expression starting at C:\Users\nzimm\github\ZipArchives.jl\mmap.jl:16
Inserting GC.gc() between the call to reading() and the file deletion fixes the issue.
GC is an expensive call. Assuming mmap doesn't need everything GC does, can mmap (or close) do what ever is needed for itself so the GC call becomes unnecessary?
This issue is discussed in the Discourse here where it is reported that it doesn't arise in Linux.
gives
Inserting
GC.gc()between the call toreading()and the file deletion fixes the issue.GCis an expensive call. Assumingmmapdoesn't need everythingGCdoes, canmmap(orclose) do what ever is needed for itself so the GC call becomes unnecessary?This issue is discussed in the Discourse here where it is reported that it doesn't arise in Linux.