Skip to content

Commit

Permalink
fix(material/badge): resolve memory leak (#29676)
Browse files Browse the repository at this point in the history
The badge had an extra unnecessary check which meant that it would sometimes leak memory through the style loader. This isn't a big deal on the client since there's usually only one app on the page, but it can be a problem on the server which can create and destroy an app for each request.

Note that this is no longer an issue in 19.x where we use the common style loader, but we need to backport the fix to 18.x.

Fixes angular/angular#57529.
  • Loading branch information
crisbeto committed Sep 2, 2024
1 parent 5d93395 commit 0f07b25
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/material/badge/badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,7 @@ export class MatBadge implements OnInit, OnDestroy {

appRef.onDestroy(() => {
badgeApps.delete(appRef);
if (badgeApps.size === 0) {
componentRef.destroy();
}
componentRef.destroy();
});
}

Expand Down

0 comments on commit 0f07b25

Please sign in to comment.