Skip to content

Fix memory leaks in adeft scorer C extension - #84

Merged
steppi merged 3 commits into
gyorilab:masterfrom
steppi:memory_leak
Nov 24, 2025
Merged

Fix memory leaks in adeft scorer C extension#84
steppi merged 3 commits into
gyorilab:masterfrom
steppi:memory_leak

Conversation

@steppi

@steppi steppi commented Nov 24, 2025

Copy link
Copy Markdown
Collaborator

While training Adeft models I noticed very large memory utilization, particularly for very frequent shortforms appearing in many texts. The pattern was suspicious, so I investigated with tracemalloc in a Python script and found the memory usage was occurring in adeft/scoring._score.c generated from adeft/scoring/_score.pyx. Further investigation with Valgrind found some mallocs missing an associated free. There were also some mallocs where sizeof was applied to the wrong type that Valgrind identified that I've also fixed. The patch in this PR dramatically reduced memory consumption, making the full Adeft model training process feasible to run out on my home workstation.

@steppi

steppi commented Nov 24, 2025

Copy link
Copy Markdown
Collaborator Author

I'm going to go ahead and merge this. After also addressing #74 I'll cut a new Adeft release.

@steppi
steppi merged commit e3f1d29 into gyorilab:master Nov 24, 2025
12 checks passed
Sign up for free to 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.

1 participant