Closed jipolanco closed 23 hours ago
Thanks for your quick response.
If I understand correctly, finalize
just calls unsafe_free!
, which is also used in the linked CUDA.jl implementation, so I'm not sure I see how one could avoid such an expensive operation. Or would it make sense to simply replace the call to finalize
with unsafe_free!
to be more explicit?
Or would it make sense to simply replace the call to
finalize
withunsafe_free!
to be more explicit?
Yeah. finalize
invokes the GC, which is slow. It's not that unsafe_free!
is slow.
Right, I didn't think about that. I'll use unsafe_free!
then.
This fixes a reference counting issue when using
resize!
on aJLVector
.The issue is illustrated by the following example:
Without this PR, the last two lines incorrectly give 1 and 0 when it should be the opposite.
This means in particular that doing things like
copy(u)
afterresize!
failed withArgumentError: Attempt to use a freed reference.
.