I want to investigate the memory usage of a python program that uses numpy.memmap to access data from large files. Is there a way to check the size in memory that a memmap is currently using? I tried sys.getsizeof on the numpy object and the _mmap attribute of the object, but both gave the same very small size regardless of how much the memmap object had been used.
Is there a way to know how much memory a numpy.memmap is currently using?
376 views Asked by Colin At
1
I found that
array.base
gives you ammap.mmap
instance (assuming thatarray
is anumpy.memmap
instance).mmap.mmap
supportslen
, so I am now using:If you know that your array is exactly a
numpy.memmap
and feel confident about making that assumption in your code,len(array.base)
would suffice.