-
-
Notifications
You must be signed in to change notification settings - Fork 111
fix: make InterfaceCache stateless and prevent memoryleak
#4645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: make InterfaceCache stateless and prevent memoryleak
#4645
Conversation
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. This PR effectively addresses the critical memory leak issue by removing static caching that held references to stale Roslyn compilation objects. The approach is sound—trading a minor performance cost for eliminating unbounded memory growth is the right call for source generators, where correctness and resource efficiency are paramount. The stateless design simplifies the code and removes cache invalidation concerns, making the implementation more maintainable going forward. |
|
Thanks for finding this issue! |
No problem, easy mistake to made. I am a little worried that a smaller memory leak is happening as #4644 still shows a small increase each time we rerun the generator. This might just be a quirk of the test or compilation, or it could be another leak. I don't see many likely culprits though 🤔 |
|
Can we run it through |
|
Good idea, never used it before but it seems appropriate. I fruitlessly tried comparing dot memory snapshots, needless I'm no expert in these kinds of issues.
On the plus side, the leak (if it exists) seems fairly small. If it's proportionate to the size of the project then it'll be fairly benign in most real world smaller test projects Again this might be a quirk of the test. Has anyone ever reported an ide memory usage issue? |
Make
InterfaceCachestateless to prevent creating static references toINamedTypeSymboland creating a memory leakSee #4644