Skip to content

free output array and median heap on window==1 in move_median#571

Merged
neutrinoceros merged 1 commit into
pydata:masterfrom
sahvx655-wq:move-median-w1-leak
Jun 3, 2026
Merged

free output array and median heap on window==1 in move_median#571
neutrinoceros merged 1 commit into
pydata:masterfrom
sahvx655-wq:move-median-w1-leak

Conversation

@sahvx655-wq

Copy link
Copy Markdown
Contributor

move_median allocates its output array with PyArray_EMPTY in INIT, then both dtype variants take an early return when window is 1. The float variant frees the median heap there but leaks that output array; the integer variant leaks both the array and the heap because it never calls mm_free either. I noticed it reading the two siblings side by side. Repeated calls with window=1 leak an input-sized array every time, so it accumulates fast. Free the array and the heap before returning, matching the normal exit path.

@neutrinoceros neutrinoceros left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Thank you !

@neutrinoceros neutrinoceros merged commit 9759092 into pydata:master Jun 3, 2026
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants