What is 'JNI Global reference'

后端 未结 3 649
面向向阳花
面向向阳花 2020-12-05 07:14

I am using jProfiler to find memory leaks in a Java swing application. I have identified instances of a JFrame which keeps growing in count.

This frame is opened, an

3条回答
  •  猫巷女王i
    2020-12-05 07:39

    Wikipedia has a good overview of Java Native Interface, essentially it allows communication between Java and native operating system libraries writen in other languages.

    JNI global references are prone to memory leaks, as they are not automatically garbage collected, and the programmer must explicitly free them. If you are not writing any JNI code yourself, it is possible that the library you are using has a memory leak.

    edit here is a bit more info on local vs. global references, and why global references are used (and how they should be freed)

提交回复
热议问题