Pass an array from a JNI function without copying

I am trying to use JNI to process large chunks of data using C ++, but I am having problems understanding the weather. The SetArrayRegion function will duplicate the array element by element or if it can just leave the data in place and return it to a java call.

The following documentation is where I read about it, but it is not yet clear what is going on. http://download.oracle.com/javase/1.5.0/docs/guide/jni/spec/functions.html

Thanks for the help.

+4
source share
1 answer

Usually, when you pass data through the JNI, it will be copied across the JNI border. If you need an efficient mechanism for transferring data from your native space to your Java space, you should look at how to access direct NIO bytes. This can provide a partition of memory that can be shared between native code and Java code. See GetDirectBufferAddress .

+4
source

All Articles