File tree Expand file tree Collapse file tree
dev/benchmarks/complex_layout/test_driver
packages/flutter_driver/lib/src/driver Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,6 +26,9 @@ void main() {
2626 // benchmark has greater noise.
2727 // See: https://github.com/flutter/flutter/issues/19434
2828 await Future <void >.delayed (const Duration (milliseconds: 250 ));
29+
30+ await driver.forceGC ();
31+
2932 final Timeline timeline = await driver.traceAction (() async {
3033 // Find the scrollable stock list
3134 final SerializableFinder list = find.byValueKey (listKey);
Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ void main() {
2727 // Let app become fully idle.
2828 await Future <void >.delayed (const Duration (seconds: 2 ));
2929
30+ await driver.forceGC ();
31+
3032 final Timeline timeline = await driver.traceAction (() async {
3133 expect (await driver.setSemantics (true ), isTrue);
3234 });
Original file line number Diff line number Diff line change @@ -137,6 +137,7 @@ class FlutterDriver {
137137 static const String _setVMTimelineFlagsMethodName = '_setVMTimelineFlags' ;
138138 static const String _getVMTimelineMethodName = '_getVMTimeline' ;
139139 static const String _clearVMTimelineMethodName = '_clearVMTimeline' ;
140+ static const String _collectAllGarbageMethodName = '_collectAllGarbage' ;
140141
141142 static int _nextDriverId = 0 ;
142143
@@ -791,6 +792,22 @@ class FlutterDriver {
791792 return result;
792793 }
793794
795+ /// Force a garbage collection run in the VM.
796+ Future <void > forceGC () async {
797+ try {
798+ await _peer
799+ .sendRequest (_collectAllGarbageMethodName, < String , String > {
800+ 'isolateId' : 'isolates/${_appIsolate .numberAsString }' ,
801+ });
802+ } catch (error, stackTrace) {
803+ throw DriverError (
804+ 'Failed to force a GC due to remote error' ,
805+ error,
806+ stackTrace,
807+ );
808+ }
809+ }
810+
794811 /// Closes the underlying connection to the VM service.
795812 ///
796813 /// Returns a [Future] that fires once the connection has been closed.
You can’t perform that action at this time.
0 commit comments