--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
2011/6/7 Антон Иванов <wkyb...@gmail.com>:
2011/6/7 Stephen Williams <scie...@gmail.com>:
when write data in c:
env->SetIntArrayRegion( sg_jImage,
0,
__size__,
pixel_data );
and in java, i can use sg_jImage in java.
but i find it too slow for me, maybe because of SetIntArrayRegion call.
so i try to use DirectBuffer as flows:
ByteBuffer.allocateDirect(__size__);
In native code:
void* buf = (void*)env->GetDirectBufferAddress((jobject)jobj);
now i can use buf in my native code.
and i find it much faster than the first one.
2011/6/8 Stephen Williams <stephend...@gmail.com>:
--
There's actually no explicit method you can call from Java to destroy or deallocate a direct buffer. When you allocate a direct buffer, the VM effectively registers a "cleanup" method with the garbage collector which will should be called at some point once the ByteBuffer object itself is no longer reachable (informally, when it is "ready to be garbage collected")1, in order to deallocate the underlying memory that was reserved for that buffer.
Usually, this "automatic" deallocation works well enough. But it's important to bear in mind that there's no immediate link between the last time you access a direct buffer and the point at which the memory is actually deallocated.
sdw