JNI ERROR (App bug): Local reference table overflow (max=512) __jni

Source: Internet
Author: User

This is a bug that I accidentally tested when I took on someone else's work.

The reason is that a function is called continuously in a loop in the JNI layer, which returns the Jobject type, and each time the function produces a local reference, which is returned and cannot be released.

This error occurs when there are too many loops and more than 512 times.

WORKAROUND: When calling the function in a loop, pass in a jobject* type parameter, which is a pointer to the Jobject, and then release the local reference within that loop

Root cause: When the Java code enters the JNI layer native code call, Dalvik creates a local reference table to store the locals reference, this table

The number of table entries has the maximum limit, the general maximum is 512, the local reference table only when the call to exit the JNI layer code will be cleared away.

When the number of table entries exceeds the maximum limit, Dalvik throws an exception, causing a crash.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.