Android: Native process provoke ReferenceTable overflow after a while (android-ndk)

前端 未结 1 1562
遥遥无期
遥遥无期 2021-02-09 13:15

Using the ndk I have compiled a code written in C. The program is a ecm format files conversion, here the native code: link . I chose to do with JNI for reasons of optimization

相关标签:
1条回答
  • 2021-02-09 13:18

    Maybe you are not freeing some references that you have allocated, for example doing lots of strings with env->NewStringUTF(path). The system does not take care of it when you are in native code. Either you need to delete it yourself or you need to let the system return to java code!

    See http://java.sun.com/docs/books/jni/html/refs.html#27567

    5.2 Freeing References

    Each JNI reference consumes a certain amount of memory by itself, in addition to the memory taken by the referred object. As a JNI programmer, you should be aware of the number of references that your program will use at a given time. In particular, you should be aware of the upper bound of the number of local references your program can create at any point during its execution, even though these local references will eventually be freed automatically by the virtual machine. Excessive reference creation, however transient, can lead to memory exhaustion.

    0 讨论(0)
提交回复
热议问题