Skip to content

Commit b5f1214

Browse files
authored
Avoid OOM errors when logging many events (#1376)
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: flutter/flutter#87100
1 parent 9d10ec7 commit b5f1214

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

dwds/lib/src/services/chrome_proxy_service.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -847,15 +847,15 @@ ${globalLoadStrategy.loadModuleSnippet}("dart_sdk").developer.invokeExtension(
847847
Future<void> parseDebugEvent(DebugEvent debugEvent) async {
848848
if (terminatingIsolates) return;
849849

850-
var isolate = _inspector?.isolate;
851-
if (isolate == null) return;
850+
var isolateRef = _inspector?.isolateRef;
851+
if (isolateRef == null) return;
852852

853853
_streamNotify(
854854
EventStreams.kExtension,
855855
Event(
856856
kind: EventKind.kExtension,
857857
timestamp: DateTime.now().millisecondsSinceEpoch,
858-
isolate: isolate)
858+
isolate: isolateRef)
859859
..extensionKind = debugEvent.kind
860860
..extensionData = ExtensionData.parse(
861861
jsonDecode(debugEvent.eventData) as Map<String, dynamic>));
@@ -868,15 +868,17 @@ ${globalLoadStrategy.loadModuleSnippet}("dart_sdk").developer.invokeExtension(
868868

869869
var isolate = _inspector?.isolate;
870870
if (isolate == null) return;
871-
872871
var service = registerEvent.eventData;
873872
isolate.extensionRPCs.add(service);
873+
874+
var isolateRef = _inspector?.isolateRef;
875+
if (isolateRef == null) return;
874876
_streamNotify(
875877
EventStreams.kIsolate,
876878
Event(
877879
kind: EventKind.kServiceExtensionAdded,
878880
timestamp: DateTime.now().millisecondsSinceEpoch,
879-
isolate: isolate)
881+
isolate: isolateRef)
880882
..extensionRPC = service);
881883
}
882884

0 commit comments

Comments
 (0)