[release/8.0] [Blazor] Fix hot reload memory leak #53928
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix hot reload memory leak
Fixes an issue where a memory leak caused hot reload edits in Blazor Web apps to take an increasing amount of time over the course of a hot reload session.
Backport of #53750 and #53827
Description
There is a static
ClearCachemethod that is expected to be implemented by the hot reload extension model. This method was not being implemented for Blazor'sHotReloadService. This PR adds that callback and forwards it to the data source to dispose the last change token in a thread safe manner. The PR also cleans up a few other smaller missingDisposecalls for this scenario.Fixes #52757
Customer Impact
Without this fix, if customers make more than 15 or 20 hot reload edits in a single hot reload session for their Blazor Web app, hot reload edits grind to a halt until the application gets restarted. We've received significant customer feedback that this impacts their workflow.
Regression?
This bug is specific to Blazor Web apps, which are new in .NET 8.
Risk
The only changes introduced are those that allow the correct disposal of hot reload state, and functionality is otherwise unchanged. The fix was verified both locally and with automated tests.
Verification
Packaging changes reviewed?