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

Avoid retaining memory while waiting for changes #67982

Merged
merged 2 commits into from
Apr 27, 2023

Conversation

sharwell
Copy link
Member

@sharwell sharwell commented Apr 26, 2023

Fixes AB#1809058

@sharwell sharwell requested a review from a team as a code owner April 26, 2023 16:46
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 26, 2023
CyrusNajmabadi
CyrusNajmabadi previously approved these changes Apr 26, 2023
@sharwell sharwell marked this pull request as draft April 26, 2023 17:04
@sharwell sharwell dismissed CyrusNajmabadi’s stale review April 26, 2023 17:18

This PR was completely rewritten to address a failure to clear all copies of data in a value type

@sharwell sharwell marked this pull request as ready for review April 26, 2023 17:18
/// <summary>
/// The workspace this request is for, if applicable. This will be present if <see cref="Document"/> is
/// present. It will be <see langword="null"/> if <c>requiresLSPSolution</c> is false.
/// </summary>
public readonly Workspace? Workspace;
public Workspace? Workspace => _lspSolution?.Value.Workspace;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make the exception a bit clearer if you use this after ClearSolutionContext is called? I assume you're doing the StrongBox to differentiate "this never had it" and "this was cleared", but that's not really confirmed anywhere.

(and frankly, I'm not sure why these wouldn't just throw if requiresLSPSolution is set, since I'd imagine that's a developer oops, but maybe I'm missing some context here)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you're doing the StrongBox to differentiate "this never had it" and "this was cleared"

No, the StrongBox<> is required because every time RequestContext is passed as an argument, a new copy is made. We need a common storage location for the references to Workspace and Solution that applies to all copies equally.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

➡️ Added code to throw for access to these properties if the solution context was initially available and has since been cleared.

@sharwell sharwell merged commit 1ec6e88 into dotnet:main Apr 27, 2023
@sharwell sharwell deleted the clear-request branch April 27, 2023 12:59
@ghost ghost added this to the Next milestone Apr 27, 2023
@Cosifne Cosifne modified the milestones: Next, 17.7 P2 May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants