6.6. Resource Management
One of the most obvious differences between Java and C++ is the model for managing resources. In Java, you simply drop references to unused objects and trust the garbage collector to reclaim memory when necessary. In C++, you typically take explicit control of resource deallocation. The JNI boundary must provide a sensible mapping between these two programming styles. There are four interesting cases to consider:
How does native code communicate with the garbage collector to manage the lifetime of Java objects?
How does Java code manage the lifetime of native objects?
How does JNI handle arrays?
How does JNI handle strings?
Arrays are a special case because Java accesses and stores arrays in a way that is not necessarily ...
Get Component Development for the Java™ Platform now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.