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
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.