Skip to content

Conversation

@jmert
Copy link
Owner

@jmert jmert commented Apr 25, 2024

In Julia 1.11+ with the new Memory object, the memory is not actually owned by the constructed Array and therefore the finalizer may trigger too early when the underlying memory is transfered from an Array to a different kind of owner (such as IOBuffer).

Fix this by conditionally checking for the Julia 1.11+ behavior, and instead setting the finalizer on the Memory, if necessary.

Duplicates the improvement made to the Mmap stdlib's implementation: JuliaLang/julia#54210

In Julia 1.11+ with the new `Memory` object, the memory is not actually
owned by the constructed `Array` and therefore the finalizer may
trigger too early when the underlying memory is transfered from an
`Array` to a different kind of owner (such as `IOBuffer`).

Fix this by conditionally checking for the Julia 1.11+ behavior, and
instead setting the finalizer on the `Memory`, if necessary.

Duplicates the improvement made to the Mmap stdlib's implementation:
JuliaLang/julia#54210
@jmert jmert force-pushed the jw/jl_memory_finalizer branch from 77ad496 to a95270e Compare April 25, 2024 20:32
@jmert jmert merged commit 0c5e5e5 into master May 21, 2024
@jmert jmert deleted the jw/jl_memory_finalizer branch May 21, 2024 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant