2

I have seen multiple questions on this subject but haven't seen a single answer to how to actually fix it other than attempting a different form of script.

Here is a simplified example. I am running this in an iPython console in Spyder with Python 2.7:

import numpy as np
X = np.zeros([1000, 1000, 50]) #works just fine
X = np.zeros([1000, 1000, 100]) #creates a MemoryError

I went to Windows Task Manager and see that Python is only using ~260 MB out of the total 2 GB that my PC has. I know that I need to save a lot of RAM for system processes, but come on, I can spare more memory than this for Python. Knowing that I need to not set it too high in order to avoid catastrophic system damage, where in Spyder or Python itself can I go to increase the maximum memory allowed?

juanpa.arrivillaga
  • 88,713
  • 10
  • 131
  • 172
Forklift17
  • 2,245
  • 3
  • 20
  • 32
  • 3
    What version, *exactly*, of Python are you using? Is it a 32-bit version of Python? What does `import sys; print(sys.maxsize)` give you? There is no "setting" of the maximum amount of memory Python will use, that is up to the OS. And this has nothing to do with Spyder. – juanpa.arrivillaga Jan 31 '19 at 18:42
  • I am running Python 2.7.10, 32-bit. sys.maxsize gives: 2147483647. Am I locked into this maxsize with this version of Python? – Forklift17 Jan 31 '19 at 20:42
  • 2
    Yes, a 32bit process will have at most 4 gigabytes of address space, which limits your memory allocation, but many OS have a different limit, I believe Window's is quite restrictive. Use a 64bit version of Python. – juanpa.arrivillaga Jan 31 '19 at 21:08

0 Answers0