I'm working with continuos calculations, which producing a lot of double arrays from C library. Using BridJ caused to real memory consumption problem.
By VisualVM tool i figured out that all allocated and released pointers are still exist in memory and being garbaged only after manual invocation of GC.
Here it is my code, may be i did something wrong..:
Sorry for forgetting this issue, I believe it was a duplicate of #440, fixed 4 months after you filed this one.
I'll make sure your use-case is fixed before closing.
From @haron4igg on May 27, 2013 20:26
Hi Olivier,
I'm working with continuos calculations, which producing a lot of double arrays from C library. Using BridJ caused to real memory consumption problem.
By VisualVM tool i figured out that all allocated and released pointers are still exist in memory and being garbaged only after manual invocation of GC.
Here it is my code, may be i did something wrong..:
NativeCalculatorLibrary.OutputCallback callback = new NativeCalculatorLibrary.OutputCallback() { @Override public void apply(double v, Pointer doubles, double v2) {
if (doubles != null && listener != null) {
double [] input = doubles.getDoubles(dimension);
listener.onReceivePoints(v, input, v2);
doubles.release();
}
}
};
I had a similar problem with JNI, but it was fixed by deleting local environment reference after performing callback.
Thank you in advance, Igor.
Copied from original issue: ochafik/nativelibs4java#404