Skip to content

fix memory leaks in examples - #19

Merged
yuvalif merged 1 commit into
lancedb:mainfrom
yuvalif:fix-examples-mem-leaks
Feb 23, 2026
Merged

yuvalif merged 1 commit into
lancedb:mainfrom
yuvalif:fix-examples-mem-leaks

Conversation

@yuvalif

@yuvalif yuvalif commented Feb 17, 2026

Copy link
Copy Markdown
Collaborator

Fixes: #18

@yuvalif yuvalif added the bug Something isn't working label Feb 17, 2026
@yuvalif
yuvalif requested a review from Copilot February 22, 2026 19:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to eliminate memory leaks in the C++ examples (as reported in issue #18), primarily by ensuring Arrow C ABI schemas and query results returned from the C API are properly released/freed.

Changes:

  • Release exported ArrowSchema instances (c_schema.release) after use in example table creation / writes.
  • Track result batch count in examples/simple.cpp search helper so returned Arrow arrays can be freed correctly.
  • Free Arrow query results returned by LanceDB (lancedb_free_arrow_arrays, lancedb_free_arrow_schema) in simple.cpp and full.cpp.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.

File Description
examples/simple.cpp Adds schema releases and frees query result Arrow allocations; refactors search return type to include batch count.
examples/s3.cpp Releases exported Arrow schema after table creation to reduce leaks.
examples/full.cpp Releases exported schemas in more places and frees Arrow query results produced by nearest-to queries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread examples/simple.cpp Resolved
Comment thread examples/full.cpp Resolved
Comment thread examples/simple.cpp Resolved
Comment thread examples/simple.cpp Resolved
Comment thread examples/s3.cpp Resolved
Comment thread examples/full.cpp Resolved
Comment thread examples/simple.cpp Resolved
Comment thread examples/simple.cpp Resolved
Comment thread examples/simple.cpp Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread examples/simple.cpp Resolved
Comment thread examples/simple.cpp Resolved
Comment thread examples/simple.cpp Resolved
Comment thread include/lancedb.h Resolved
Fixes: lancedb#18

Signed-off-by: Yuval Lifshitz <[email protected]>
@yuvalif
yuvalif force-pushed the fix-examples-mem-leaks branch from 3bef428 to dd6d957 Compare February 23, 2026 11:41
@yuvalif
yuvalif merged commit 91740d1 into lancedb:main Feb 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

memory leaks in examples

2 participants