[SciPy-User] memory errors when using savemat

Pauli Virtanen pav@iki...
Sun Jul 25 11:49:10 CDT 2010

Sat, 24 Jul 2010 10:37:33 -0700, Tyrel Newton wrote:
> I'm trying to use scipy.io.savemat to export a very large set of data to
> a .mat file. The dataset contains around 20 million floats. When I try
> to export this to a .mat file, I get a MemoryError. The specific
> MemoryError is:
> File "C:\Python26\lib\site-packages\scipy\io\matlab\miobase.py", line
> 557 in write_bytes
> 	self.file_stream.write(arr.tostring(order='F'))

What is the complete error message? -- It typically indicates the 
specific part in C code the error originates from. (The full traceback, 

On the other hand, along that code path it seems the only source of a 
MemoryError can really be a failure to allocate memory for the tostring. 
Your data apparently needs 160 MB free for this to succeed -- which is 
not so much. So the question comes to what is the memory usage of the 
code when saving, compared to the available free memory?

Pauli Virtanen

More information about the SciPy-User mailing list