title: How can I find out why using PIL functions is resulting in a memory error?
body: <p>I am using PIL (python image library) to do some image manipulation, specifically I am stitching images together. </p>
  
  <p>My code seems to work fine for some images in small quantities, but sometime I and getting a <code>MemoryError</code>. </p>
  
  <p>The part that is particularly strange to me is that I am not doing manipulations on bit images, its all work with &lt;10 images under 10kb. </p>
  
  <p>I am making a lot of calls to <code>Image.resize</code>, but I am surprised that there are significant issues from that. </p>
  
  <p>Here is the stack track:</p>
  
  <pre><code>Traceback (most recent call last):                                                                                                                                               
    File "test.py", line 15, in &lt;module&gt;                                                                                                                                           
      pprint(scale_matrix_down((90,90), [inpt]))                                                                                                                                   
    File "/Users/jeremykarmel/Desktop/Python/merger.py", line 105, in scale_matrix_down                                                                                            
      return [shrinkRow(row, row_width_overflow(row)) for row in matrix]                                                                                                           
    File "/Users/jeremykarmel/Desktop/Python/merger.py", line 103, in shrinkRow                                                                                                    
      rest         = [shrinkIm(im, pixels_per_im) for im in row[remaining_pixels:]]                                                                                                
    File "/Users/jeremykarmel/Desktop/Python/merger.py", line 110, in shrinkIm                                                                                                     
      return im.resize((im.size[0] - num_pix, im.size[1] - num_pix))                                                                                                               
    File "/Library/Python/2.7/site-packages/PIL/Image.py", line 1302, in resize                                                                                                    
      im = self.im.resize(size, resample)                                                                                                                                          
  MemoryError
  </code></pre>
  
  <p>Keep in mind the images are all less than 90x90 pixels. </p>
  
  <p>I am very much at a dead end and really not sure how to proceed. What can I do to release the memory? Should I be calling the del operator or is there something simpler I can do? 
  Thanks in advance for your help!</p>