Fix memory leak in overload resolution#3089
Fix memory leak in overload resolution#3089samschlegel wants to merge 1 commit intofacebook:mainfrom
Conversation
|
Hi @samschlegel! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Summary: Replace fresh partial variable allocation with snapshot/restore during overload evaluation. The freshen_partial_vars approach created new solver variables for every overload candidate. These accumulated in the solver's variable map and were never freed, causing unbounded memory growth in certain codebases (e.g. 90MB -> 49GB on a play_scraper repro, though not reproducible on numpy or other large projects — the specific trigger is unclear). Instead, snapshot partial var state before evaluating overloads and restore after each attempt. This prevents losing overloads from pinning partial vars without allocating new variables.
3506e8f to
b623698
Compare
Summary
Replace fresh partial variable allocation with snapshot/restore during overload evaluation.
The freshen_partial_vars approach created new solver variables for every overload candidate. I think these accumulated in the solver's variable map and were never freed, causing unbounded memory growth in certain codebases (e.g. 90MB -> 49GB on a play_scraper repro.) This isn't reproducible on numpy or other large projects, so the specific trigger is unclear.
Instead, snapshot partial var state before evaluating overloads and restore after each attempt. This prevents losing overloads from pinning partial vars without allocating new variables.
Fixes #3088
Test Plan [WIP]
cargo teststest.py