Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unmap of NumPy memmap

Tags:

python

numpy

mmap

I can't find any documentation on how numpy handles unmapping of previously memory mapped regions: munmap for numpy.memmap() and numpy.load(mmap_mode).

My guess is it's done only at garbage collection time, is that correct?

like image 676
Radim Avatar asked Jun 18 '11 16:06

Radim


People also ask

What is memmap NumPy?

Memory-mapped files are used for accessing small segments of large files on disk, without reading the entire file into memory. NumPy's memmap's are array-like objects. This differs from Python's mmap module, which uses file-like objects.

How do I deactivate Memmap?

As far as I understand, there are currently two ways to close a memmap "file"; del fp or fp.


1 Answers

Yes, it's only closed when the object is garbage-collected; memmap.close method does nothing.

You can call x._mmap.close(), but keep in mind that any further access to the x object will crash python.

like image 95
Igor Nazarenko Avatar answered Oct 19 '22 08:10

Igor Nazarenko