Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@MackinnonBuck
Copy link
Member

@MackinnonBuck MackinnonBuck commented Feb 9, 2024

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 ClearCache method that is expected to be implemented by the hot reload extension model. This method was not being implemented for Blazor's HotReloadService. 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 missing Dispose calls 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?

  • Yes
  • No

This bug is specific to Blazor Web apps, which are new in .NET 8.

Risk

  • High
  • Medium
  • Low

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

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

jacdavis and others added 2 commits February 9, 2024 15:24
Fix of razor hotreload change token leak. This disposes the
old change tokens after the ClearCache event or before overwriting. 
If something goes wrong and this isn't cleared
before the next invocation of UpdateEndpoints on the
razor data source, clear it and dispose of it then.
* Add unit test to confirm change token is disposed during
razer hot reload.

* Per Makinnon's feedback, switch to a callback model
to create the wrapped disposable for this unit test.

* Update src/Components/Endpoints/test/HotReloadServiceTests.cs

---------

Co-authored-by: Mackinnon Buck <[email protected]>
@MackinnonBuck MackinnonBuck added Servicing-consider Shiproom approval is required for the issue area-blazor Includes: Blazor, Razor Components labels Feb 9, 2024
@MackinnonBuck MackinnonBuck requested a review from a team as a code owner February 9, 2024 23:37
@dotnet-policy-service dotnet-policy-service bot added this to the 8.0.x milestone Feb 9, 2024
@mkArtakMSFT mkArtakMSFT added Servicing-approved Shiproom has approved the issue and removed Servicing-consider Shiproom approval is required for the issue labels Feb 12, 2024
@wtgodbe wtgodbe merged commit 414f0d4 into release/8.0 Feb 12, 2024
@wtgodbe wtgodbe deleted the mbuck/backport-53750-to-8.0 branch February 12, 2024 21:19
@dotnet-policy-service dotnet-policy-service bot modified the milestones: 8.0.x, 8.0.3 Feb 12, 2024
@dotnet-policy-service dotnet-policy-service bot added the area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework label Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework Servicing-approved Shiproom has approved the issue

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

7 participants