FFI_RecordBatchStream was causing a memory leak#17190
Merged
alamb merged 2 commits intoapache:mainfrom Aug 19, 2025
Merged
Conversation
timsaucer
added a commit
to rerun-io/rerun
that referenced
this pull request
Aug 14, 2025
…mpletion. This is a temporary work around for apache/datafusion#17190
alamb
approved these changes
Aug 18, 2025
Contributor
alamb
left a comment
There was a problem hiding this comment.
Thank you @timsaucer -- this makes sense to me
| } | ||
|
|
||
| unsafe extern "C" fn release_fn_wrapper(provider: &mut FFI_RecordBatchStream) { | ||
| let private_data = |
Contributor
There was a problem hiding this comment.
I double checked that the private_data is actually a RecordBatchStreamPrivateData that is created with the constructor
datafusion/datafusion/ffi/src/record_batch_stream.rs
Lines 80 to 84 in 327f8bc
Contributor
|
I also merged up from main |
timsaucer
added a commit
to timsaucer/datafusion
that referenced
this pull request
Aug 21, 2025
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
alamb
added a commit
that referenced
this pull request
Aug 21, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
When using the foreign function interface, a
Box<RecordBatchStreamPrivateData>is created but it is never properly freed. This leads to a growth in memory over time as these are used.What changes are included in this PR?
Adds a
releasefunction to FFI_RecordBatchStream and implementsDrop.Are these changes tested?
Tested against
datafusion-pythonwhere it is easy to track memory growth and to implement FFI based table providers.Are there any user-facing changes?
None