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

Fix S1215 FN: GC.GetTotalMemory(forceFullCollection: true) should not be called #9687

Open
fiotti opened this issue Oct 21, 2024 · 1 comment
Labels
Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues. Type: False Negative Rule is NOT triggered when it should be.

Comments

@fiotti
Copy link

fiotti commented Oct 21, 2024

Description

GC.GetTotalMemory(forceFullCollection: true) calls GC.Collect() internally.

It might make sense to consider it equivalent to GC.Collect() and trigger a S1215.

Repro steps

GC.Collect(); // S1215: Refactor the code to remove this use of 'GC.Collect'.

GC.GetTotalMemory(true); // No warning.

Expected behavior

GC.Collect(); // S1215: Refactor the code to remove this use of 'GC.Collect'.

GC.GetTotalMemory(true); // S1215: Refactor the code to remove this use of 'GC.GetTotalMemory', or do not set 'forceFullCollection' to true.

Actual behavior

No warning.

Known workarounds

None.

Related information

  • SonarLint for Visual Studio 2022 v8.5.0.10497
@mary-georgiou-sonarsource
Copy link
Contributor

Hello @fiotti.
Thanks for reporting this. Indeed that's what I also see in the source code .
I'll add this to our backlog.

@Tim-Pohlmann Tim-Pohlmann added Type: False Negative Rule is NOT triggered when it should be. Area: VB.NET VB.NET rules related issues. Area: C# C# rules related issues. labels Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues. Type: False Negative Rule is NOT triggered when it should be.
Projects
None yet
Development

No branches or pull requests

3 participants