There were experiments adding an explicit "unmap this bigarray" operation to the runtime: see Apr 2012 commit
  https://github.com/ocaml/ocaml/commit/2330a3b30fe5b910f4776bf9c41f35ce2b980fb1
However, this change was reverted shortly thereafter because of performance concerns: it changes the invariant that the size of a live bigarray never changes, which makes it easier to optimize away bound checks.

Could you please create a bug report ( http://caml.inria.fr/mantis/ ) to keep track of your particular issue with lack of explicit bigarray closure? I haven't found traces of it in the bugtracker ( the rather old bug http://caml.inria.fr/mantis/view.php?id=3571 is about the need to call msync() in a NFS setting, but doesn't touch explicit closure ), so it may not have been previously known.

On Thu, Sep 18, 2014 at 10:04 AM, Bauer, Christoph <bauerchristoph@siemens.com> wrote:

Dear All,

 

my program maps  several blocks of a file into memory with Bigarray.Array1.map_file for writing.

Finally the file handle is closed with Unix.close.

 

On local files system everything works as expected. But if the file is on a network drive,

the resulting file is after the close still  locked [1] and it contains just zeros.

 

My workaround is, to call  Gc.full_major() before the close. Then all remaining bigarrays are

finalized (the finalizer calls caml_ba_unmap_file(), see bigarray_stubs.c).

 

Calling Gc.full_major () is somewhat dissatisfying. But I’m not sure how it could be solved more cleanly.

I would expect that Unix.close should unmap all remaining views of the file. But Unix.close knows nothing

about the bigarray mapping.

 

Maybe a special Bigarray.unmap is the solution.

 

Does anyone has a better idea?

 

Thanks,

Christoph Bauer

 

[1] You can’t delete it in the windows explorer.

 

 

-----------------
Siemens Industry Software GmbH & Co. KG; Anschrift: Franz-Geuer-Str. 10, 50823 Köln;
Kommanditgesellschaft: Sitz der Gesellschaft: Köln; Registergericht: Amtsgericht Köln, HRA 28227;
Geschäftsführung und persönlich haftender Gesellschafter: Siemens Industry Software Management GmbH;
Geschäftsführer: Urban August, Daniel Trebes; Sitz der Gesellschaft: Köln; Registergericht: Amtsgericht Köln, HRB 70858