Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set finalizer on underlying Memory object in Julia 1.11+ #11

Merged
merged 1 commit into from
May 21, 2024

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 merged commit 0c5e5e5 into master May 21, 2024
11 checks passed
@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