Dear Benjamin,

I encountered a rather severe memory leak when using pygsl_rng.dirichlet_lnpdf. I'm using gsl 1.8 via pygsl 0.3.2.

The following code snippet reproduces the error:

import pygsl.rng
for i in range(800000):
    pygsl.rng.dirichlet_lnpdf([1.1,1.1,1.1,1.1],[[0.25,0.25,0.25,0.25]])

When running this you will see the memory consumption increase monotonously.

The problem did not occur when I implemented the density function myself using pygsl.sf.gamma, nor for a C test script that called gsl_ran_dirichlet_pdf directly. This seems to indicate that the problem resides somewhere in the pygsl interface to gsl_ran_dirichlet_pdf.

Thanks for the report. Two arrays were not dereferenced and thus started to eat up the memory...

A patch is added. I also checked it into CVS but it takes time until one can retrieve it from anonymous cvs. If required I can send you the full file as well.

Sincerely yours
        Pierre
Index: src/rng/rng_helpers.c
===================================================================
RCS file: /cvsroot/pygsl/pygsl/src/rng/rng_helpers.c,v
retrieving revision 1.4
diff -u -r1.4 rng_helpers.c
--- src/rng/rng_helpers.c       4 Jan 2005 12:18:28 -0000       1.4
+++ src/rng/rng_helpers.c       19 Apr 2006 15:01:21 -0000
@@ -1129,6 +1129,8 @@
               assert(0);
          }
      }
+     Py_DECREF(array_p);
+     Py_DECREF(array_n);
      return (PyObject *) array_out;
  fail:
      FUNC_MESS("FAIL");

Reply via email to