From 62444dcb275f1b812fcb869e4142083c75c02bc9 Mon Sep 17 00:00:00 2001 From: Nicholas Shahan Date: Mon, 2 Aug 2021 16:08:32 -0700 Subject: [PATCH] Avoid OOM errors when logging many events Revert to attaching the IsolateRef instead of the Isolate to the postEvent and registerExtension events. The Isolate is much larger and was causing systems to run out of memory when event traffic was high like in Flutter where they are sent on every animation frame. See: https://github.com/flutter/flutter/issues/87100 --- dwds/lib/src/services/chrome_proxy_service.dart | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/dwds/lib/src/services/chrome_proxy_service.dart b/dwds/lib/src/services/chrome_proxy_service.dart index 80fb3c39d..b58fbb616 100644 --- a/dwds/lib/src/services/chrome_proxy_service.dart +++ b/dwds/lib/src/services/chrome_proxy_service.dart @@ -847,15 +847,15 @@ ${globalLoadStrategy.loadModuleSnippet}("dart_sdk").developer.invokeExtension( Future parseDebugEvent(DebugEvent debugEvent) async { if (terminatingIsolates) return; - var isolate = _inspector?.isolate; - if (isolate == null) return; + var isolateRef = _inspector?.isolateRef; + if (isolateRef == null) return; _streamNotify( EventStreams.kExtension, Event( kind: EventKind.kExtension, timestamp: DateTime.now().millisecondsSinceEpoch, - isolate: isolate) + isolate: isolateRef) ..extensionKind = debugEvent.kind ..extensionData = ExtensionData.parse( jsonDecode(debugEvent.eventData) as Map)); @@ -868,15 +868,17 @@ ${globalLoadStrategy.loadModuleSnippet}("dart_sdk").developer.invokeExtension( var isolate = _inspector?.isolate; if (isolate == null) return; - var service = registerEvent.eventData; isolate.extensionRPCs.add(service); + + var isolateRef = _inspector?.isolateRef; + if (isolateRef == null) return; _streamNotify( EventStreams.kIsolate, Event( kind: EventKind.kServiceExtensionAdded, timestamp: DateTime.now().millisecondsSinceEpoch, - isolate: isolate) + isolate: isolateRef) ..extensionRPC = service); }