#5 fix ll_mat memory leaking: PyArray_IterNew requires Py_DECRE

closed-accepted
nobody
None
5
2009-06-29
2009-06-26
No

Hi

I found memory leaking in ll_mat.put (SVN 118) due to missing Py_DECREF of
iterators allocated with PyArray_IterNew. Attached patch fixes the
problem in Src/ll_mat.c. The following program demonstrates the
memory leak in ll_mat.put:

import sys

from pysparse.spmatrix import ll_mat
from numpy import arange

k = 1
if len(sys.argv) > 1:
k = int(sys.argv[1])
n = 1000
a = arange(n)
b = ll_mat(n, n, n)
for x in range(k * 10000):
b.put(a, a, a)

Discussion

  • he following program demonstrates the memory leak in ll_mat.put

     
  • Dominique
    Dominique
    2009-06-29

    • summary: fix ll_mat memory leaking: PyArray_IterNew requires Py_DECREF --> fix ll_mat memory leaking: PyArray_IterNew requires Py_DECRE
    • status: open --> closed-accepted
     
  • Dominique
    Dominique
    2009-06-29

    The patch was applied as given. Thanks for spotting this!