<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/scipy/ticket/1629" rel="nofollow">http://projects.scipy.org/scipy/ticket/1629</a> on 2012-03-25 by trac user briantoby, assigned to <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/cournape/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/cournape">@cournape</a>.</em></p>
<p dir="auto">Calling scipy.fftpack.ifft2(npary) creates two arrays of size npary; one is returned but the other remains allocated. The attached routine grows in size by 256Mb on every iteration in SciPy 0.10.0 (and previous) in EPD 7.2. I have seen a similar problem, likely due to the same bug in Windows.</p>
<p dir="auto">Consider the memory usage of the following code after executing each statement:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import numpy
import scipy.signal
import gc

# memory at this point is ~35mb

a = numpy.ones(10**7)
b = numpy.ones(10**7)

# memory at this point is ~187mb

c = scipy.signal.fftconvolve(a, numpy.flipud(b), mode=&quot;full&quot;)

# memory usage at this point is 645mb
# given that a,b,c take up about 305mb in total, this is much
# larger than expected

# If we delete a,b,c and garbage collect...

del a,b,c
gc.collect()

# ...the memory usage drops to ~340mb which is a drop of 305mb
# (as expected since that is the size of what we deleted)
# but the remaining memory usage is still 340mb
# which is much larger than the starting value of 35 mb"><pre class="notranslate"><code class="notranslate">import numpy
import scipy.signal
import gc

# memory at this point is ~35mb

a = numpy.ones(10**7)
b = numpy.ones(10**7)

# memory at this point is ~187mb

c = scipy.signal.fftconvolve(a, numpy.flipud(b), mode="full")

# memory usage at this point is 645mb
# given that a,b,c take up about 305mb in total, this is much
# larger than expected

# If we delete a,b,c and garbage collect...

del a,b,c
gc.collect()

# ...the memory usage drops to ~340mb which is a drop of 305mb
# (as expected since that is the size of what we deleted)
# but the remaining memory usage is still 340mb
# which is much larger than the starting value of 35 mb
</code></pre></div>
<p dir="auto">Is this extra several hundred mb of memory usage a bug?</p>
<p dir="auto">Platform:</p>
<ul dir="auto">
<li>CPython 3.5.1 x64</li>
<li>Scipy 0.17.0 (Christoph Golke's package)</li>
<li>Numpy+MKL 1.11.0rc1 (Cristoph Golke's package)</li>
<li>Windows 8.1 x64</li>
</ul>