On Jul 30, 2009, at 3:18 PM, Andi Vajda wrote:
On Thu, 30 Jul 2009, Aric Coady wrote:
Looks like there are some memory leaks in JArray_string, when
iterating or accessing its items. I've seen it reproduce with
2.4.1 on linux and osx. Attached is a test case to demonstrate it
using Document.getValues, and a potential patch.
Arik,
I got your test case but the patch seems to be missing ?
Oh, here it is inlined. Looks like the same problem as described in http://lists.osafoundation.org/pipermail/pylucene-dev/2008-October/002939.html
.
Index: jcc/sources/JArray.h
===================================================================
--- jcc/sources/JArray.h (revision 799400)
+++ jcc/sources/JArray.h (working copy)
@@ -295,6 +295,7 @@
jstring value = (jstring)
env->getObjectArrayElement((jobjectArray) this$, i);
PyObject *obj = env->fromJString(value);
+ env->get_vm_env()->DeleteLocalRef(value);
PyList_SET_ITEM(list, i - lo, obj);
}
@@ -314,7 +315,9 @@
jstring str = (jstring)
env->getObjectArrayElement((jobjectArray) this$,
n);
- return env->fromJString(str);
+ PyObject *obj = env->fromJString(str);
+ env->get_vm_env()->DeleteLocalRef(str);
+ return obj;
}
}