Invoke Jni in Android, referencetable overflow (max=1024) appears

Source: Internet
Author: User

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

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.