[Numpy-discussion] Memory leak with numpy master

Gael Varoquaux gael.varoquaux@normalesup....
Mon Sep 24 14:05:02 CDT 2012


On Mon, Sep 24, 2012 at 07:59:11PM +0100, Nathaniel Smith wrote:
> > which means I probably forgot a DECREF while doing the
> > PyArray_Diagonal changes...

> Yep: https://github.com/numpy/numpy/pull/457

Awesome. I can confirm that this fixes the problem. Script below to check.

You are my hero!

Gael

_______________________________________________________________________________
os.system('python setup.py build_ext -i')

def get_mem_usage():
    pid = os.getpid()
    usage = open('/proc/%i/statm' % pid, 'r').read().split(' ')[0]
    return int(usage)

import numpy as np
n = 100
m = np.eye(n)
for i in range(30000):
    #np.linalg.slogdet(m)

    t, result_t = np.linalg.linalg._commonType(m)
    a = np.linalg.linalg._fastCopyAndTranspose(t, m)

    pivots = np.zeros((n,), np.linalg.linalg.fortran_int)
    results = np.linalg.lapack_lite.dgetrf(n, n, a, n, pivots, 0)
    d = np.diagonal(a)

    if i == 0:
        initial_usage = get_mem_usage()
    if not i % 1000:
        usage = get_mem_usage()
        print i, usage
        if usage > 4*initial_usage:
            sys.exit(10)

sys.exit(0)
_______________________________________________________________________________


More information about the NumPy-Discussion mailing list