Now JavaCall tries to use saved_args to keep reference of JavaObject while pass arg.ptr into JNI FFI.
|
savedArgs, convertedArgs = convert_args(argtypes, args...) |
|
result = ccall(callmethod, Ptr{Nothing}, (Ptr{JNIEnv}, Ptr{Nothing}, Ptr{Nothing}, Ptr{Nothing}), |
|
penv, obj.ptr, jmethodId, convertedArgs) |
|
result==C_NULL && geterror() |
|
return convert_result(rettype, result) |
But saved_args is not referenced after it created, it might be garbage collected at any time (even before ccall).
I learnt from this gc would only occurs when allocates memory (so current code might work now), but it is hard to trace memory allocation.
Is there any better solution that telling gc not to collect saved_args?
Now JavaCall tries to use
saved_argsto keep reference of JavaObject while passarg.ptrinto JNI FFI.JavaCall.jl/src/core.jl
Lines 244 to 248 in d6c3678
But
saved_argsis not referenced after it created, it might be garbage collected at any time (even beforeccall).I learnt from this
gcwould only occurs when allocates memory (so current code might work now), but it is hard to trace memory allocation.Is there any better solution that telling gc not to collect
saved_args?