Skip to content

Commit

Permalink
add note about memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
kenzieschmoll committed Aug 25, 2023
1 parent 4636bd4 commit a9db1f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/devtools_app_shared/lib/src/utils/globals.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ void setGlobal(Type clazz, Object instance) {

void removeGlobal(Type clazz) {
globals.remove(clazz);
assert(globals[clazz] == null);
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,18 @@ class _DevToolsExtensionState extends State<DevToolsExtension> {
setGlobal(IdeTheme, IdeTheme());
}

void _removeGlobals() {
void _shutdown() {
(globals[ExtensionManager] as ExtensionManager?)?._dispose();
removeGlobal(ExtensionManager);
removeGlobal(ServiceManager);
removeGlobal(IdeTheme);
}

@override
void dispose() async {
extensionManager._dispose();
await serviceManager.manuallyDisconnect();
_removeGlobals();
void dispose() {
// TODO(https://github.com/flutter/flutter/issues/10437): dispose is never
// called on hot restart, so these resources leak for local development.
_shutdown();
super.dispose();
}

Expand Down

0 comments on commit a9db1f8

Please sign in to comment.