Skip to content

Fix Python scalar UDF refcount leak - #245

Merged
evertlammerts merged 6 commits into
duckdb:mainfrom
Schwarf:fix/python-udf-refcount-leak
Jan 6, 2026
Merged

Fix Python scalar UDF refcount leak#245
evertlammerts merged 6 commits into
duckdb:mainfrom
Schwarf:fix/python-udf-refcount-leak

Conversation

@Schwarf

@SchwarfSchwarf commented Jan 3, 2026

Copy link
Copy Markdown
Contributor

Fixes#224
Fixes the memory leak reported in #224

The issue was caused by Python UDF return values not being released after conversion. While this affected all return types, it was only observable for large VARCHAR/bytes values due to their size. The fix ensures correct reference management using py::reinterpret_steal<py::object>.

A regression test was added to detect refcount leaks in Python scalar UDF execution.

@evertlammerts
evertlammerts added this pull request to the merge queueJan 6, 2026
@evertlammerts
evertlammerts removed this pull request from the merge queue due to a manual request Jan 6, 2026
@evertlammerts
evertlammerts added this pull request to the merge queueJan 6, 2026
@evertlammerts
evertlammerts removed this pull request from the merge queue due to the queue being cleared Jan 6, 2026
@evertlammerts
evertlammerts merged commit 77e4b02 into duckdb:mainJan 6, 2026
15 checks passed
@evertlammertsevertlammerts mentioned this pull request Jan 27, 2026
2 tasks
Sign up for freeto 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.

UDF Memory Leak

2 participants

@Schwarf@evertlammerts