7

Is there any way to see contents of the JNI local reference table?

I can see it if I got a crash when it's overflowed, via android LogCat, and there is a lot of info about referenced objects, unique instances etc. which helps to catch potential memory leaks.

Thanks.

Frederic Blase
  • 510
  • 1
  • 4
  • 15
  • I am not sure I understand your question, it might be that you get a JNI crash and would like to find out which line in your source the addresses in the stack trace correspond to, so does a look at the answer to [How to use addr2line in Android](http://stackoverflow.com/questions/5314036/how-to-use-addr2line-in-android) help you? – Raimo Ihle Oct 18 '12 at 14:38
  • 1
    @Raimo No. If I got a crash i can see this table like in the question [Android NDK overflows](http://stackoverflow.com/questions/11079912/android-ndk-overflows-dalvik-jni-local-reference-table) I wonder, if I can view this reference table during normal work of my applcation. – Frederic Blase Oct 18 '12 at 15:16
  • 1
    @Why? What good would it do you? Are you going to execute different code based on its contents? I think what you are really looking for is `PushLocalFrame()` and `PopLocalFrame()`. – user207421 Oct 19 '12 at 09:14
  • @EJP No, I want to check how my code works and improve it if I have a lot of unused local references - to prevent overflowing in future. Thx for Push/PopLocalFrame, but it's still not what I am searching for. – Frederic Blase Oct 19 '12 at 10:06
  • How exactly can you have unused local references? And if you can, how is Push/PopLocalFrame not an adequate solution? – user207421 Oct 23 '12 at 10:22
  • @EJP For example I create a lot of jobjects in a cycle - they should freed by GC when become unreferenced, but it could take some time, so the table overflows. PopLocalFrame destroys all local objects, not only unreferenced objects. – Frederic Blase Oct 23 '12 at 13:36

1 Answers1

1

Please refer CheckJNI.

It can catch number of common error. For ICS CheckJNI is on by default if debuggable="true" in your Manifest.xml.

Thanks

Sukane
  • 2,632
  • 3
  • 18
  • 19