title: How to solve memory error in python when I have 32GRAM and py is 64bit
body: <p>I am processing images using NumPy and Pillow and I have 32G of RAM, but all of the memory is being used. What can I do to improve my program? Here is my part code:</p>
  
  <pre><code>import os
  import numpy as np
  from PIL import Image
  from numpy import *
  
  img_rows,img_cols,img_depth=240,240,30
  X_tr=[]
  
  path = '/home/lt/Spyder/data1/brushing teeth/Depth1/'
  imlist = os.listdir(path)
  imlist.sort(key= lambda x:int(x[:-4]))
  im = np.array(Image.open(path+imlist[0]))
  m,n = im.shape[0:2]
  imbr = len(imlist)
  num = imbr-30 
  i = 0
  
  while i&lt;num :
      frames=[]
      for k in range(30):
          im=np.array(Image.open(path+imlist[k+i]))
          frames.append(im)
  
      i=i+5
      input=np.array(frames)
      ipt = np.rollaxis(np.rollaxis(input,2,0),2,0)
      X_tr.append(ipt) #265  
  </code></pre>
  
  <p>The size of <code>X_tr</code> variable is 3751 rows, and my memory is on 99%. What should I do? Maybe I should process 100000 images, but that is only fourth of the data!</p>