Minimize JNI Global Refs: Let Java Classes Hold Object References

Whenever feasible, avoid creating JNI global references by designing your application so that Java objects hold references to other Java objects, allowing the JVM's automatic garbage collector to manage their lifecycles, thereby reducing native memory leak risks.

Sources

Open the full topic