473,398 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

DirectBuffers

Hi,

My requirement is to use Direct Buffers and share a common memory between Java and C++.

I have created a ByteBuffer in java using allocateDirect and sent the same to JNI. In JNI i have called GetDirectBufferAddress() and got the address of ByteBuffer and sent the same to my C++ library as char* through SetByteBuffer() function.

Now i have to do getByteBuffer() from Java, which should return me the direct allocated buffer. In C++ i am returning the same char* pointer in GetByteBuffer() method and JNI is able to get the elements properly. Now i am dont now how to send this char* to Java as ByteBuffer or jByteArray() with out creating a new memory and copying the data. Can any one provide a solution to me.
Feb 16 '12 #1
0 2219

Sign in to post your reply or Sign up for a free account.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.