Closed cocoa-xu closed 10 months ago
Instead of releasing it in the code, wouldn't it better to release it on GC via a NIF destructor? The reason I ask is because if the process crashes due a Process.exit(pid, :kill)
, terminate does not run and therefore it can leak.
It seems that the GC releases the statement earlier than we want/it should be in my test...
Now it should work
Instead of using templates, could we define a destruct resource per type? Because we should define a release statement for each Adbc*Release function we have, and not only statements. WDYT? Or are templates the only way to achieve this?
Yeah we can do that. But I found that adding a destructor for AdbcConnection
will cause segfaults.
static void destruct_adbc_connection_resource(ErlNifEnv *env, void *args) {
auto res = (NifRes<struct AdbcConnection> *)args;
if (res && !res->freed) {
struct AdbcError adbc_error{};
AdbcConnectionRelease(&res->val, &adbc_error);
res->freed = true;
}
}
Yeah we can do that. But I found that adding a destructor for AdbcConnection will cause segfaults.
Can you please push those changes? Then I can try to debug locally as well :)
Sure, I've pushed the code!
Closing in favor of #53.
Try to release statement if possible. Related to issue #50.