Access pointer to java buffer array - forcing GetByteArrayElements NOT to c

Hello,

I need to pass a Big binary data from java through JNI to a device driver.

If I directly use the dll and create an application, then data transfer is 2Mbps. But if I use JNI and transfer data from java, speed is 100Kbps.

SO there is a bottleneck in JNI.

When i tried the function GetByteArrayElements, it is always creating a copy of the big memory before transfering each block. This could be a potential reason for this.

jboolean *isCopy;

char* cTxbuffer = (char *)(env)->GetByteArrayElements(txbuffer,isCopy);

if(*isCopy == JNI_TRUE)

cout<<"ISCOPY"; // code executes here

else

cout<<"ISNOTCOPY";

My JVM always crestes a copy for the same.

So my questions.

1) Can anybody a suggest a function to directly get the pointer in JNI to java byte array created in java?

2) Can I force GetByteArrayElements NOT to create a copy?

Sugestions and ides are welcome.

thank you,

Boby Thomas

[1013 byte] By [bobypta] at [2007-11-27 6:08:47]
# 1
There is a way to use fixed memory in JNI and java. You will have to look it up since I can't remember it. You need to use it carefully. If I remember correctly you want to set up the initial buffer as one of the very first things your application does.
jschella at 2007-7-12 17:11:40 > top of Java-index,Java HotSpot Virtual Machine,Specifications...