Ext.: http://m.blog.csdn.net/blog/redouba/20624631
Recently in the Android Monitoring project, when the call. So library decoding, the long run time will be reported referencetable overflow (max=1024) error. And then search on the Internet, the general result is that there are no resources to release the various.
Resources:
Problem Source: wrote a more complex native so library, which used a linked list, extracted data from the linked list, loaded into the Java LinkedList. There is no problem when the test data is small, referencetable overflow (max=512) error occurs when the test data reaches a certain scale. Problem Solving: 1. By reading the JNI documentation, it is necessary to call Deletelocalref for Findclass return, as well as jbytearray types of variables that need to be deletelocalref. In my code, these are already processed, and those are local REF? newstring/newstringutf/newobject/getobjectfield generated, didn't it? Through tests found that these are, Local Ref. 2. Although the above found all changed, but still appear referencetable overflow (max=512) error, through the code to read the discovery. One code is written in this way. setobjectfield (DWI, Jfid, Env->newstringutf (szdatetime)) The problem is in Env->newstringutf (szdatetime) Place, Because this writing is also seen in the Sun JNI documentation, because it is in the loop of the list, before the Exit function, the JNI Newstringutf produced locelref constantly, resulting in referencetable overflow (max=512). Summary: 1. Findclass/newstring/newstringutf/newobject/getobjectfield, and so on, are localref,localref three ways to be cleaned up by the GC of the VM. 2. Do not study the Setobjectfield (DWI, Jfid, Env->newstringutf (szdatetime)) similar to the following in the Sun JNI documentation. http://blog.csdn.net/win2k3net/article/details/6613440 various inspection found in the file resources have also been released, why will the error! is a headache, can not continue to find it, the heaven does not bear. I finally found the: is caused by not releasing the resources before return. Reference: http://bbs.csdn.net/topics/390445365 problem finally solved, thank you predecessors, eldest brother Elder sisters, uncle aunt
Invoke Jni in Android, referencetable overflow (max=1024) appears