Closed ghost closed 10 years ago
I suspect on windows you need to call close
before mmap_array. The example should be updated to reflect this.
I've been noticing this in a few packages (https://github.com/timholy/HDF5.jl/issues/89 for example), so thanks for reducing it!
How would mmap'ing a closed file work?
julia> A2 = mmap_array(Int, (m,n), s)
ERROR: could not create mapping view
in mmap_array at mmap.jl:139
julia> close(s)
julia> A2 = mmap_array(Int, (m,n), s)
ERROR: could not get handle for file to map
in mmap_array at mmap.jl:122
Maybe if you insert the close
statement prior to https://github.com/JuliaLang/julia/blob/master/base/mmap.jl#L138? I can't test this myself, unfortunately.
Does not appear to fix things - different error though, ERROR: could not create file mapping
. I'm happy to test any more ideas you can come up with.
Maybe windows doesn't support mmap if the file position is non-zero? Try seek(s,0)
before mmap? You can pass an offset as an extra argument to mmap_array
.
That looks more promising. seek(s,0)
works for this case - but non-zero offsets don't.
I wonder if any multiple of the pagesize works.
One could change the code to extract the current position, seek(s,0)
, and then offset the pointer passed to pointer_to_array
.
I tested two things:
@timholy's suggestion sounds worth trying. If I wasn't about to leave for a conference for the rest of the week I'd take a crack at it.
Ah, looks like #6203 has a suggested implementation of something similar, I'll give the code there a try
I tried to run the following mmap_array example and it doesn't work as it throws an error when calling mmap_array under Win7.