IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
22.6 Forcing file updates and closing the Memmap


22.6 Forcing file updates and closing the Memmap

After doing slice resizes or inserting new slices, call flush to synchronize the underlying map file with any free floating slices. This explicit step is required to avoid implicitly shuffling huge amounts of file space for every resize or insert. After calling flush, all slices are once again memory mapped rather than free floating.

>>> m.flush()

A related concept is ``syncing'' which applies even to arrays which have not been resized. Since memory maps don't guarantee when the underlying file will be updated with the values you have written to the map, call sync when you want to be sure your changes are on disk. This is similar to syncing a UNIX file system. Note that sync does not consolidate the mapfile with any free floating slices (newly inserted or resized), it merely ensures that mapped slices whose contents have been altered are written to disk.

>>> m.sync()

Now "a" and "b" are both memory mapped on "memmap.tst" again.

When you're done with the memory map and numarray, call close. close calls flush which will consolidate resized or inserted slices as necessary.

>>> m.close()

It is an error to use "m" (or slices of m) any further after closing it.

Send comments to the NumArray community.