Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

numpy.memmap returns not enough memory while there are plenty available

During a typical call to numpy.memmap() on a 64bit windows machine, python raise the following error:

OSError: [WinError 8] Not enough memory resources are available to process this command

A different windows machine raise the same error with a different text:

OSError: [WinError 8] Not enough storage is available to process this command.

Here is the code abstract:

with open(infile, 'rb') as f:
  ......
  array = numpy.memmap(f, dtype='uint8', mode='r', offset=offset, shape=arraysize).tolist()

Python only used 50MB of the memory by this time. What would be the cause of running out of memory?

like image 338
auzn Avatar asked Oct 18 '25 07:10

auzn


1 Answers

It turns out the issue here is that the offset + shape in the memmap call is greater than the total size of the file (i.e. I am trying to read beyond the size of the file).

The error message about memory resource is a little misleading in this case.

like image 102
auzn Avatar answered Oct 19 '25 21:10

auzn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!