On some devices our app crash at startup with the following error (but on same device owned by other people, no problem) :
Abort message: ‘art/runtime/indirect_reference_table.cc:113] JNI ERROR (app bug): local reference table overflow (max=512)’
Here the full dump from Android developer console :
Hello I have the same issue with my application, I’ve understand that the problem is that we are allocating too many times the same object in a loop and JNI accept a maximum of 512 allocation of local reference. I use a coroutine in which an array is assigned each loop and I’m searching for a method to clear the previous allocation.
have you already managed the problem? could you help me?
I don’t think that it could help, because I’m using a Inertial sensors for multiple bluetooth communication in streaming for android. I’m using a plugin for BT communication in Android using Unity by techTweaking (you can find it in asset store). I need to be fast so firstly i’ve used a coroutine in my main and now I’m trying with fixed update. My problem is, apparently, that the assignation blockReceived = device.read(); has too many local reference (more or less 500 before crash). Do you know a conceptual reason for this? how could i clear the content in my local reference map?
The conceptual reason is that JNI limits the number of local references and you have to either push/pop frames or delete local references once you no longer need them to avoid overflow.
For the later, we do have an API: https://docs.unity3d.com/ScriptReference/AndroidJNI.DeleteLocalRef.html
However, with knowing what AndroidJava/JNI APIs you are using I can’t help you more. You mentioned something about putting elements into array. Could you paste that piece of code?