openframeworks / openframeworks/openFrameworks
Failed adding to JNI pinned array ref table (1024 entries)
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
when running a videograbber on a device the application is continuously pinning the image data array:
W/dalvikvm: JNI: pin count on array 0x4234bf90 ([F) is now 1022
when a maximum pin count of 1024 is reached, the application crashes:
W/dalvikvm: ReferenceTable overflow (max=1024)
W/dalvikvm: JNI pinned array reference table (0x52e34008) dump:
W/dalvikvm: Last 10 entries (of 1024):
W/dalvikvm: 1023: 0x4234bf90 float[] (16 elements)
W/dalvikvm: 1022: 0x4234bf90 float[] (16 elements)
W/dalvikvm: 1021: 0x4234bf90 float[] (16 elements)
W/dalvikvm: 1020: 0x4234bf90 float[] (16 elements)
W/dalvikvm: 1019: 0x4234bf90 float[] (16 elements)
W/dalvikvm: 1018: 0x4234bf90 float[] (16 elements)
W/dalvikvm: 1017: 0x4234bf90 float[] (16 elements)
W/dalvikvm: 1016: 0x4234bf90 float[] (16 elements)
W/dalvikvm: 1015: 0x4234bf90 float[] (16 elements)
W/dalvikvm: 1014: 0x4234bf90 float[] (16 elements)
W/dalvikvm: Summary:
W/dalvikvm: 1024 of float[] (16 elements) (1 unique instances)
E/dalvikvm: Failed adding to JNI pinned array ref table (1024 entries)
I/dalvikvm: "main" prio=5 tid=1 RUNNABLE
I/dalvikvm: | group="main" sCount=0 dsCount=0 obj=0x42063de0 self=0x42052478
I/dalvikvm: | sysTid=29053 nice=0 sched=0/0 cgrp=apps handle=1074315604
I/dalvikvm: | state=R schedstat=( 0 0 0 ) utm=4183 stm=554 core=0
I/dalvikvm: at cc.openframeworks.OFAndroidVideoGrabber.newFrame(Native Method)
I/dalvikvm: at cc.openframeworks.OFAndroidVideoGrabber.onPreviewFrame(OFAndroidVideoGrabber.java:345)
I/dalvikvm: at android.hardware.Camera$EventHandler.handleMessage(Camera.java:980)
I/dalvikvm: at android.os.Handler.dispatchMessage(Handler.java:102)
I/dalvikvm: at android.os.Looper.loop(Looper.java:136)
I/dalvikvm: at android.app.ActivityThread.main(ActivityThread.java:5139)
I/dalvikvm: at java.lang.reflect.Method.invokeNative(Native Method)
I/dalvikvm: at java.lang.reflect.Method.invoke(Method.java:515)
I/dalvikvm: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:796)
I/dalvikvm: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
I/dalvikvm: at dalvik.system.NativeStart.main(Native Method)
E/dalvikvm: VM aborting
A/libc: Fatal signal 6 (SIGABRT) at 0x0000717d (code=-6), thread 29053 (.grabberTestAnd)
Application terminated.
looking into ofxAndroidVideoGrabber.cpp i can see that the byte-array gets released when not used anymore: env->ReleaseByteArrayElements(array, (jbyte*)currentFrame, 0); but somehow the pin-count on the array is not reduced.
i tried what is proposed in this stackoverflow post: https://stackoverflow.com/questions/18668135/jni-memory-leak-from-byte-array#18668319 without any change in the behaviour.
of code:
void ofApp::setup(){
grabber.initGrabber(320, 240);
}
void ofApp::update(){
grabber.update();
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ofxAndroidVideoGrabber.cpp, the native newFrame path, and the Java callback at OFAndroidVideoGrabber.java:345; reproduce the videograbber case on an Android device while tracing the array release path. Done means repeated preview frames no longer increase the JNI pinned-array count until the 1024-entry reference table overflows.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, cpp
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100