[SciPy-user] memory leak in numarray 1.1

Peter Dobcsanyi peter at designtheory.org
Sun Nov 14 07:44:39 CST 2004


Hi, 

I have already started a thread on comp.lang.python about this problem
but thought would post it here too.

Calling the following function with a large enough 'n' causes memory
leak.

    import numarray as N

    def loop(n, m=100):
        for i in xrange(n):
            a = N.zeros((m,m))
            N.matrixmultiply(a, a)

If the matrixmultiply line is commented out, there is no leak, the
program has a stable memory size.  With n a few hundreds (say n>=500),
the continuous growth of the program's memory footprint is quite
noticeable. I am working on Linux (Debian testing), I monitor the memory
usage of the program by top.  The allocated memory is never released.

I have noticed this problem of memory leak in connection with numarray a
few months ago in a program of mine. The program processes the incidence
matrices of thousands of combinatorial structures read from a file one
by one. As the number of combinatorial objects went up I started running
out of memory even on a machine with 2 Gbyte memory and with small
(m<100) matrices.  It took me a while to pinpoint that it was caused by
matrix multiplication.

Following Robert Kern's suggestion I have also tried the development
version from CVS and that does not leak.

    Peter



More information about the SciPy-user mailing list