O'Reilly logo

Component Development for the Java™ Platform by Stuart Dabbs Halloway

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

  1. How does native code communicate with the garbage collector to manage the lifetime of Java objects?

  2. How does Java code manage the lifetime of native objects?

  3. How does JNI handle arrays?

  4. How does JNI handle strings?

Arrays are a special case because Java accesses and stores arrays in a way that is not necessarily ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required