I am sending large amounts of data from Java to C++ using JNI and in an attempt to minimize the cost of transferring the data and avoid unnecessary copies, I tried implementing GetDirectBufferAddress to access the memory location directly instead of GetDoubleArrayElements. I also ran performance metrics on both methods from the Java side via System.currentTimeMillis()
and got the following performance times:
GetDoubleArrayElements: 98 ms GetDirectBufferAddress: 96 ms
Virtually no performance increase. Is there any reason this might be happening? I allocated the ByteBuffers on the Java side using ByteBuffer.allocateDirect().order(ByteOrder.nativeOrder)
and arrBuff.putDouble(arr[i])
. Am I missing something? Any reference material would be greatly appreciated, I'm just trying to learn.