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

JNI ERROR (app bug): local reference table overflow (max=512) #15

Closed
tshirtman opened this issue Aug 21, 2012 · 3 comments
Closed

JNI ERROR (app bug): local reference table overflow (max=512) #15

tshirtman opened this issue Aug 21, 2012 · 3 comments

Comments

@tshirtman
Copy link
Member

tshirtman commented Aug 21, 2012

Loading some classes on android simply break because of the limit of jni reference table, would be great to find a way around this.

Exemple found just now, that crashes kivy-remote-shell on its own.

>>> from jnius import autoclass
>>> WebView = autoclass('android.webkit.WebView')

Connection to 192.168.0.10 closed by remote host.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/1362797-jni-error-app-bug-local-reference-table-overflow-max-512?utm_campaign=plugin&utm_content=tracker%2F77133&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F77133&utm_medium=issues&utm_source=github).
@jitendranair
Copy link

Same here, I am using the android java contacts api and the app crashes due to this error

JNI ERROR (app bug): local reference table overflow (max=512)
W/dalvikvm(27097): JNI local reference table (0x57901190) dump:
W/dalvikvm(27097):   Last 10 entries (of 512):
W/dalvikvm(27097):       511: 0x41e5e950 android.os.Parcel
W/dalvikvm(27097):       510: 0x41e594f0 android.os.BinderProxy
W/dalvikvm(27097):       509: 0x41e53f80 java.lang.String "552"
W/dalvikvm(27097):       508: 0x41eb0018 java.lang.String[] (1 elements)
W/dalvikvm(27097):       507: 0x41f083a8 java.lang.String "551"
W/dalvikvm(27097):       506: 0x41e53f30 java.lang.String "contact_id = ?"
W/dalvikvm(27097):       505: 0x41f07230 java.lang.String "545"
W/dalvikvm(27097):       504: 0x416c70e0 java.lang.Class<java.lang.String>
W/dalvikvm(27097):       503: 0x41edbdf0 java.lang.String "1730"
W/dalvikvm(27097):       502: 0x416c70e0 java.lang.Class<java.lang.String>
W/dalvikvm(27097):   Summary:
W/dalvikvm(27097):       267 of java.lang.Class (18 unique instances)
W/dalvikvm(27097):       242 of java.lang.String (242 unique instances)
W/dalvikvm(27097):         1 of java.lang.String[] (1 elements)
W/dalvikvm(27097):         1 of android.os.Parcel
W/dalvikvm(27097):         1 of android.os.BinderProxy
E/dalvikvm(27097): Failed adding to JNI local ref table (has 512 entries)

@KeyWeeUsr
Copy link
Contributor

@tshirtman ref this answer and #371. I'm not sure we would be able to somehow overcome this. If the table has that limitation, we can only make sure we remove our references right after we don't need them. We might try to store the refs on the Python side, but I don't think JNI would be happy about that and it'd just collect the objects or just return segfault, no?

However we might switch to PushLocalFrame()/PopLocalFrame() in places where we create our local refs to be really sure the refs are gone, though it might cause more harm due to us not being able to track the refs and we might end up with prematurely collected refs.

Minor sidenote: I've been able to autoclass('android.webkit.WebView') just fine and I don't think my JNI table size has been altered, so I'd say #371 did a good job for fixing this issue and I'd close it.

@KeyWeeUsr
Copy link
Contributor

KeyWeeUsr commented Jan 31, 2019

In Android versions prior to Android 8.0, the number of local references is capped at a version-specific limit. Beginning in Android 8.0, Android supports unlimited local references.

ref Android JNI docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants