<p dir="auto">See <a href="https://github.com/scikit-image/scikit-image/issues/954" data-hovercard-type="issue" data-hovercard-url="/scikit-image/scikit-image/issues/954/hovercard">the reported issue</a> and particularly <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="29972216" data-permission-text="Title is private" data-url="https://github.com/scikit-image/scikit-image/issues/954" data-hovercard-type="issue" data-hovercard-url="/scikit-image/scikit-image/issues/954/hovercard?comment_id=177239362&amp;comment_type=issue_comment" href="https://github.com/scikit-image/scikit-image/issues/954#issuecomment-177239362">scikit-image/scikit-image#954 (comment)</a> for the details.</p>
<p dir="auto">From what I've succeded to track, this may be related to a direct <code class="notranslate">malloc</code> call:<br>
<a href="https://github.com/scipy/scipy/blob/master/scipy/ndimage/src/nd_image.c#L835-L837">1</a> -&gt; <a href="https://github.com/scipy/scipy/blob/05dc7b8b0662c9c973203b36044458ca35084833/scipy/ndimage/src/ni_morphology.c#L114-L115">2</a> -&gt; <a href="https://github.com/scipy/scipy/blob/05dc7b8b0662c9c973203b36044458ca35084833/scipy/ndimage/src/ni_support.c#L518">3</a>.</p>
<p dir="auto">Original reported on the scipy-user list: <a href="http://thread.gmane.org/gmane.comp.python.scientific.user/36123" rel="nofollow">gmane</a></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import numpy as np
from scipy import ndimage

arr = np.zeros((1024, 1024))

arr_filt = ndimage.median_filter(arr, 150)
"><pre class="notranslate"><code class="notranslate">import numpy as np
from scipy import ndimage

arr = np.zeros((1024, 1024))

arr_filt = ndimage.median_filter(arr, 150)

</code></pre></div>
<p dir="auto">The call to <code class="notranslate">ndimage.median_filter</code> requires allocating a 4050000000  byte  (= 150 * 150 * 150 * 150 * 8) buffer.  This buffer is allocated in NI_InitFilterOffsets, on <a href="https://github.com/scipy/scipy/blob/master/scipy/ndimage/src/ni_support.c#L518">line 518, in ni_support.c</a> which is called from <a href="https://github.com/scipy/scipy/blob/master/scipy/ndimage/src/ni_filters.c#L726">line 726 of ni_filter.c</a>, in Ni_RankFilter.</p>