[chemfp] chemfp memory leak in 1.1 and older
Andrew Dalke
dalke at dalkescientific.com
Wed Feb 6 22:22:57 EST 2013
Hi all,
Nothing like a new release to shake out bugs!
There's a chemfp memory leak bug only affects people who make and
free many arenas. I think few people actually do that.
I will put out a 1.1p1 within a day or so with this fix. If you
want it now, it's available from the Google Code repository.
Here's the full report.
I added the new "FingerprintArena.copy()" method so I could generate
extract many random subsets from an arena. This evening I realized
that my analysis code used a lot more memory than it should have.
I pinned it down to my misunderstanding in how Py_BuildValue works.
I had code like:
PyObject *new_arena = make_string(...);
return Py_BuildValue("O", new_arena);
The "O" character code returns a Python object, but it also adds a
new reference count to it, which I didn't expect. This meant that
my arena strings would never be deallocated. The correct version uses:
return Py_BuildValue("N", new_arena);
which returns a Python object with "N"o reference count changes.
I've added the regression test "test_memory.py" which tests each
use of Py_BuildValue with either an "O" or an "N" to make sure that
it now returns the correct result.
Andrew
dalke at dalkescientific.com
More information about the chemfp
mailing list