Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lookup_java_object_name leaks LocalRefs #68

Closed
zielmicha opened this issue Aug 2, 2013 · 2 comments
Closed

lookup_java_object_name leaks LocalRefs #68

zielmicha opened this issue Aug 2, 2013 · 2 comments

Comments

@zielmicha
Copy link
Contributor

Actually manages to leak 3 references each call!

git pull https://github.com/zielmicha/pyjnius

Or patch:

diff --git a/jnius/jnius_utils.pxi b/jnius/jnius_utils.pxi
index 7d893b4..05d54f7 100644
--- a/jnius/jnius_utils.pxi
+++ b/jnius/jnius_utils.pxi
@@ -77,6 +77,9 @@ cdef bytes lookup_java_object_name(JNIEnv *j_env, jobject j_obj):
     cdef jmethodID jmeth = j_env[0].GetMethodID(j_env, jcls2, 'getName', '()Ljava/lang/String;')
     cdef jobject js = j_env[0].CallObjectMethod(j_env, jcls, jmeth)
     name = convert_jobject_to_python(j_env, b'Ljava/lang/String;', js)
+    j_env[0].DeleteLocalRef(j_env, js)
+    j_env[0].DeleteLocalRef(j_env, jcls)
+    j_env[0].DeleteLocalRef(j_env, jcls2)
     return name.replace('.', '/')
@tito
Copy link
Member

tito commented Aug 2, 2013

oh wha, could you make a PR from your main branch?

@tito
Copy link
Member

tito commented Aug 2, 2013

ok, patch merged from your PR

@tito tito closed this as completed Aug 2, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants