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

Fix pyarrow memory leak (#3683) #3893

Merged
merged 4 commits into from
Mar 21, 2023

Conversation

tustvold
Copy link
Contributor

@tustvold tustvold commented Mar 21, 2023

Which issue does this PR close?

Closes #3683

Rationale for this change

This is a follow on to #3685 that removes the deprecated methods, and fixes a remaining memory leak.

What changes are included in this PR?

Are there any user-facing changes?

@github-actions github-actions bot added the arrow Changes to the arrow crate label Mar 21, 2023
@tustvold tustvold force-pushed the fix-pyarrow-memory-leak branch 2 times, most recently from d2b50c4 to 8573b38 Compare March 21, 2023 13:11
Remove ArrowArray::into_raw and try_from_raw
@tustvold tustvold force-pushed the fix-pyarrow-memory-leak branch from 8573b38 to 9028daa Compare March 21, 2023 13:18
@@ -118,9 +118,6 @@ struct ArrayPrivateData {

impl FFI_ArrowArray {
/// creates a new `FFI_ArrowArray` from existing data.
/// # Memory Leaks
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is out-of-date, FFI_ArrowArray frees memory automatically on drop

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that it means that consumer of FFI_ArrowArray (might be in other language like JVM) should call release as C Data Interface defines to release it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps, but from the context of Rust it is just a little bit confusing, as release isn't even publicly visible 😅

@alamb alamb requested a review from viirya March 21, 2023 13:30
@@ -66,6 +51,7 @@ pub unsafe fn make_array_from_raw(
/// This function copies the content of two FFI structs [ffi::FFI_ArrowArray] and
/// [ffi::FFI_ArrowSchema] in the array to the location pointed by the raw pointers.
/// Usually the raw pointers are provided by the array data consumer.
#[deprecated(note = "Use FFI_ArrowArray::new and FFI_ArrowSchema::try_from")]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above methods are not only safe, but less likely to accidentally leak memory

@tustvold tustvold merged commit 3a6f8bd into apache:master Mar 21, 2023
spebern pushed a commit to spebern/arrow-rs that referenced this pull request Mar 25, 2023
* Fix pyarrow memory leak (apache#3683)

Remove ArrowArray::into_raw and try_from_raw

* Update docs

* Further deprecation

* Clippy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PyArrowConvert Leaks Memory
2 participants