I have an application with high perf. requirements.
The problem at hand is that I need to invoke some Java API to copy a native (C++) array into disk, from a Java API. The data is going to be big, so I want to avoid copies from C to Java land. I want just to pass a reference to the data in some way and serialize that data
The problem is that if I send a byte[]
the Java GC will delete it and we do not want this to happen.
I thought of wrapping my native array data in a class/struct in C++ but at the end I need a byte[]
stream or similar in the Java side. Is there a way I can cast some reference to some data in C++ to byte[]
in Java, and immediately after that leave that memory alone, avoiding the GC to recycle it?