Skip to content

Commit 920a6e0

Browse files
committed
fix dashboard memory leak (#64154)
1 parent f190fe2 commit 920a6e0

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/plugins/dashboard/public/application/dashboard_app_controller.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,12 @@ export class DashboardAppController {
620620
ReactDOM.render(<navigation.ui.TopNavMenu {...getNavBarProps()} />, dashboardNavBar);
621621
};
622622

623+
const unmountNavBar = () => {
624+
if (dashboardNavBar) {
625+
ReactDOM.unmountComponentAtNode(dashboardNavBar);
626+
}
627+
};
628+
623629
$scope.timefilterSubscriptions$ = new Subscription();
624630

625631
$scope.timefilterSubscriptions$.add(
@@ -968,6 +974,9 @@ export class DashboardAppController {
968974
});
969975

970976
$scope.$on('$destroy', () => {
977+
// we have to unmount nav bar manually to make sure all internal subscriptions are unsubscribed
978+
unmountNavBar();
979+
971980
updateSubscription.unsubscribe();
972981
stopSyncingQueryServiceStateWithUrl();
973982
stopSyncingAppFilters();
@@ -981,6 +990,9 @@ export class DashboardAppController {
981990
if (outputSubscription) {
982991
outputSubscription.unsubscribe();
983992
}
993+
if (dashboardContainer) {
994+
dashboardContainer.destroy();
995+
}
984996
});
985997
}
986998
}

0 commit comments

Comments
 (0)