[Numpy-discussion] setmember1d memory leak?

Per B. Sederberg persed at princeton.edu
Mon Jan 22 16:06:09 EST 2007

Robert Kern <robert.kern <at> gmail.com> writes:

> Per B. Sederberg wrote:
> > Does anyone have any idea of what might be occurring in setmember1d in
> > combination with this setup that would cause such a massive memory leak?
> Can you check out numpy from SVN and see if you can reproduce the leak? 
> I do not
> see a leak with a recent checkout on OS X with the following code:
> In [15]: from numpy import *
> In [16]: ar1 = arange(1000000)
> In [17]: ar2 = arange(3, 7)
> In [18]: import itertools
> In [19]: for i in itertools.count(1):
>    ....:    if not i % 1000:
>    ....:        print i
>    ....:    x = setmember1d(ar1, ar2)

I tried it out and your test code does NOT break with the svn version of numpy,
but memory use explodes with the current stable release.  We're talking using up
2GB in around 20 seconds.

So the next question is what changed to fix that bug?  It looks like the only
difference in the code is that the call to argsort now has (kind='mergesort').

Also, why does setmember1d require unique elements?  It seems as though that
really narrows its uses.


More information about the NumPy-Discussion mailing list