Skip to content Skip to sidebar Skip to footer

Error Saving And Loading A List Of Matrices

I have a list 'data_list', and I would save it in order to load it in another script. First of all I converted it in an array, in this way: data_array = np.array(data_list) Then I

Solution 1:

MemoryError is an out of memory condition. This explains why it happens with objects of at least a certain size - more and bigger arrays, as you would expect, require more memory. What the max size is, and why it seems to have changed, is harder. This can be highly specific to your system, especially in regard to considerations like:

  • How much memory (physical RAM and swap space) exists and is available to the operating system
  • How much virtual memory the OS gives to Python
  • How much of that you're already using
  • The implementation of the C library, especially of its malloc function, which can affect how Python uses the memory it is allocated

And possibly quite a few other things.

Per the comments, it seems the biggest problem here is that you are running a 32 bit build of Python. On Windows, 32 bit processes apparently have an effective maximum memory address space of around 2GB. By my tests, the list of arrays you are using by itself might take around a quarter of that. The fact that your error only comes up when reading the file back in suggests that numpy deserialisation is relatively memory intensive, but I don't know enough about its implementation to be able to say why that would be. In any case, it seems like installing a 64 bit build of Python is your best bet.

Post a Comment for "Error Saving And Loading A List Of Matrices"