We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1288

Summary: Android_JNI_FileOpen should release object references before exiting
Product: SDL Reporter: Gabriel Jacobo <gabomdq>
Component: fileAssignee: Sam Lantinga <slouken>
Status: RESOLVED DUPLICATE QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: tim
Version: HG 2.0   
Hardware: ARM   
OS: Android (All)   

Description Gabriel Jacobo 2011-08-25 04:27:28 UTC
I happened to hit an object reference limit that exists in the Java VM of Android. If you load a bunch of files from Native Code without returning to Java at any point in between, the VM doesn't have the opportunity to clear up this references, and you end up getting an exception when the referenced objects reach 512.
The solution to this, according to online documentation, is to use the PushLocalFrame/PopLocalFrame functions. So in Android_JNI_FileOpen you'd have to open with:

mEnv->PushLocalFrame(10);

and before each return:

mEnv->PopLocalFrame(NULL);

I've tested this solution in my project and it seems to be working fine (see http://mdqinc.com/blog/2011/08/sdl-under-android/ for reference).
Comment 1 Tim Angus 2011-08-26 03:15:08 UTC
Ah, just noticed this. I've added a patch to bug #1261 to deal with this.
Comment 2 Tim Angus 2011-08-26 03:15:34 UTC

*** This bug has been marked as a duplicate of bug 1261 ***