Fix dart2js batch mode memory leak
The CompilerOptions.onError closure indirectly referenced the previous
CompilerOptions object. The onError closure also referenced most of
the dart2js state. This in effect made a linked-list of the dart2js
compilations.
Change-Id: Ibb4f514fc7be5a4d2fb4453e41631f064c0bf0d6
Reviewed-on: https://dart-review.googlesource.com/63321
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
diff --git a/pkg/front_end/lib/src/api_unstable/dart2js.dart b/pkg/front_end/lib/src/api_unstable/dart2js.dart
index 943eacf..3ce7148 100644
--- a/pkg/front_end/lib/src/api_unstable/dart2js.dart
+++ b/pkg/front_end/lib/src/api_unstable/dart2js.dart
@@ -78,5 +78,9 @@
return compilerResult;
});
+ // Remove these parameters from [options] - they are no longer needed and
+ // retain state from the previous compile. (http://dartbug.com/33708)
+ options.onError = null;
+ options.fileSystem = null;
return compilerResult?.component;
}