title: Releasing memory of huge numpy array in IPython
body: <p><em>UPDATE:- This problem solved itself after a machine reboot. Not yet able to figure out why this error was happening before.</em></p>
  
  <p>I have a function that loads a huge numpy array (~ 980MB) and returns it.</p>
  
  <p>When I first start Ipython and call this function, it loads the array into the variable without any problem.</p>
  
  <p>But if I run the same command again, it exits raising a "Memory Error".</p>
  
  <p>I tried the following,</p>
  
  <pre><code>del hugeArray
  </code></pre>
  
  <p>Still the same error was occurring.
  I even tried the following</p>
  
  <pre><code>del hugeArray
  gc.collect()
  gc.collect()
  </code></pre>
  
  <p>Initially, <code>gc.collect()</code> returned 145 and the second call returned 48.
  But even after this when I call the function, it was still raising a Memory error.</p>
  
  <p>The only way I could load again was to restart ipython.
  Is there something I can do to free all memory in ipython, so that I don't have to restart it?</p>
  
  <p>----------------Update</p>
  
  <p>Following is the output of <code>%whos</code></p>
  
  <pre><code>Variable   Type      Data/Info
  ------------------------------
  gc         module    &lt;module 'gc' (built-in)&gt;
  gr         module    &lt;module 'Generate4mRamp' &lt;...&gt;rom 'Generate4mRamp.pyc'&gt;
  np         module    &lt;module 'numpy' from '/us&lt;...&gt;ages/numpy/__init__.pyc'&gt;
  plt        module    &lt;module 'matplotlib.pyplo&lt;...&gt;s/matplotlib/pyplot.pyc'&gt;
  </code></pre>
  
  <p>Out of this, gr is my module containing the function which i used to load the data cube.</p>
  
  <p>---------How to Reproduce the error</p>
  
  <p>The following simple function is able to reproduce the error.</p>
  
  <pre><code>import numpy as np
  import gc
  
  def functionH():
      cube=np.zeros((200,1024,1024))
      return cube
  
  testcube=functionH()   #Runs without any issue 
  
  del testcube
  testcube=functionH()  # Raises Memory Error
  
  del testcube
  gc.collect()
  gc.collect()
  testcube=functionH()  # Still Raises Memory Error
  </code></pre>
  
  <p><strong>This error is occurring only in Ipython. In simple python (>>>) after giving <code>del testcube</code>, there is no Memory Error.</strong></p>