Drain AnalysisDriver streams in ContextBuilderImpl.
R=brianwilkerson@google.com
Change-Id: I4b0db751452fe43f62ca836286a42ce0c72e8cca
Reviewed-on: https://dart-review.googlesource.com/64921
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/lib/src/dart/analysis/context_builder.dart b/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
index bf4d9ba..3ede35d 100644
--- a/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
@@ -83,6 +83,12 @@
contextRoot.root.path, contextRoot.excludedPaths.toList(),
pathContext: resourceProvider.pathContext);
AnalysisDriver driver = builder.buildDriver(oldContextRoot);
+
+ // AnalysisDriver reports results into streams.
+ // We need to drain these streams to avoid memory leak.
+ driver.results.drain();
+ driver.exceptions.drain();
+
DriverBasedAnalysisContext context =
new DriverBasedAnalysisContext(resourceProvider, contextRoot, driver);
return context;