java - Custom memory allocation inside JNI native function -
i need allocate array of bytes inside jni c-function. transmit array java code byte[]
object. know there function newbytearray
, takes input size of byte array, can’t use custom memory allocation functions. in case need use specific nonstandard malloc-like allocation function linux. there should no additional copying because of limited resources.
if use byte[]
, must allocate java heap , allow control memory management.
however, can use bytebuffer
, allows perform memory management in native code. can allocate chunk of memory in native code , access java without copy.
Comments
Post a Comment