I'm using JavaCPP to exploit some C++ libraries in a Java application but manipulated datas are big datas. So my code works fine but is not memory-friendly (and I need it to work fast):
- I have a big
byte[][]
to provide to the native part. - Target native function is something like
nativeFunction(PointerPointer param)
-> Doc - (To be precise, this is a
PointerPointer<BytePointer>
type expected, so a list ofBytePointer
asbyte[][]
is a list ofbyte[]
) -> Doc
I initialize the expected param this way:
byte[][] myBigDatas;
// myBigDatas.length = 4
// myBigDatas[x].length = something like 4000000
// Initialize param
PointerPointer<BytePointer> srcParam = new PointerPointer<BytePointer>(
myBigDatas[0],
myBigDatas[1],
myBigDatas[2],
myBigDatas[3]);
// Call the native function
nativeFunction(srcParam);
Problem is, referring to documentation, for each BytePointer
created by the call of PointerPointer<BytePointer>(...)
with provided data, it's not a memory wrapping, but a copy that is made.
There is a way to avoid copy ?
EDIT:
Otherwise, does JNI provide solution for give AND return byte[][]
WITHOUT COPYING IT? (I know it is for a simple byte[]
)