[Numpy-discussion] setmember1d memory leak?

Per B. Sederberg persed at princeton.edu
Mon Jan 22 15:29:10 EST 2007


Hi Everybody:

I was having a massive memory leak problem in some simulations I coded that I
traced down to the setmember1d method.  After running for about an hour, my
program, which should have been taking up .6% of the RAM was taking up 100% of
my 4GB of RAM and would eventually get killed by the system.

After replacing that method with the following inefficient code, the memory
problems disappeared and I can run for days without my memory use increasing
beyond .6%:

def ismember(a,b):
    ainb = zeros(len(a),dtype=bool)
    for item in b:
        ainb = ainb | (a==item)
    return ainb


Here's the information about my setup:

% uname -a
Linux 2.4.21-27.0.4.ELsmp #1 SMP Sat Apr 16 18:53:14 EDT 2005 x86_64 x86_64
x86_64 GNU/Linux

% python
Python 2.4.4 (#1, Jan 21 2007, 12:09:48)
[GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-49)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
%>>> import numpy
%>>> numpy.version.version
'1.0.1'
%>>>   

It is an AMD opteron machine running RedHat Enterprise with an older version of
GCC.  The same error occurred with an older version of python (the April 2006
release with version 2.4.3).

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?

Thanks,
Per






More information about the NumPy-Discussion mailing list