Skip to content
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

Found resource/memory leak from never disposing of a disposable inside of a linq query. #159

Open
AraHaan opened this issue Nov 17, 2023 · 1 comment

Comments

@AraHaan
Copy link

AraHaan commented Nov 17, 2023

The code here: https://github.com/aspnet/RoslynCodeDomProvider/blob/main/src/Microsoft.CodeDom.Providers.DotNetCompilerPlatform/Compiler.cs#L52-L56

Contains a resource/memory leak from not disposing of the disposable inside of the .Select when it gets computed at runtime for each item in it.

The best way to fix this is to use the simplified using syntax by setting <LangVersion>8</LangVersion> or newer inside of the csproj.

For .NET Framework projects I have tested that even the absolute latest language version in the latest compiler binaries (even the preview ones in VS2022 Preview) works, even when the language version of preview is used as well. Just got to be aware of what specific features to avoid however.

@AraHaan AraHaan changed the title Found memory leak from never disposing of an disposable inside of a linq query. Found memory leak from never disposing of a disposable inside of a linq query. Nov 17, 2023
@AraHaan AraHaan changed the title Found memory leak from never disposing of a disposable inside of a linq query. Found resource/memory leak from never disposing of a disposable inside of a linq query. Nov 17, 2023
@AraHaan
Copy link
Author

AraHaan commented Nov 17, 2023

I only found this when I started to port the code over myself to my own project to improve it as it seems this repository is not maintained much and I needed some much needed fixes ASAP.

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

No branches or pull requests

1 participant