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 - Android_JNI_FileOpen should release object references before exiting
Summary: Android_JNI_FileOpen should release object references before exiting
Status: RESOLVED DUPLICATE of bug 1261
Alias: None
Product: SDL
Classification: Unclassified
Component: file (show other bugs)
Version: HG 2.0
Hardware: ARM Android (All)
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-25 04:27 UTC by Gabriel Jacobo
Modified: 2011-08-26 03:15 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 ***