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.