From b785f7dba85e03d5307f99fb1ee5ec8286d39ece Mon Sep 17 00:00:00 2001 From: Martin Kustermann Date: Fri, 12 Aug 2022 21:02:54 +0000 Subject: [PATCH] Avoid logging information by-default and never discarding such logs The analyzer wraps various functionality in logging calls like await logger.runAsync('Prepare linked bundles', () async { ... }); Doing so will cause time being measured and begin/end messages to be written to a log. Those strings accumulate in a `StringBuffer` that is never accessed. For example running analyzer on a big app like flutter can cause thousands of "--- Prepare linked bundles in 0 ms. " strings to be generated and hanged on to. This CL makes us no longer generate such strings - only if the creator of a context supplies a [PerformanceLog] explicitly (in which case it is responsible for draining the messages written to it). This reduces memory consumption when analyzing flutter by around 3 MB. TEST=ci Change-Id: I4979a964f13c63bd2a3cccef97fb702431731139 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254925 Reviewed-by: Brian Wilkerson Commit-Queue: Martin Kustermann Reviewed-by: Konstantin Shcheglov --- pkg/analyzer/lib/src/dart/analysis/context_builder.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/analyzer/lib/src/dart/analysis/context_builder.dart b/pkg/analyzer/lib/src/dart/analysis/context_builder.dart index 9dcf26e857fe..f6b186c8c9ee 100644 --- a/pkg/analyzer/lib/src/dart/analysis/context_builder.dart +++ b/pkg/analyzer/lib/src/dart/analysis/context_builder.dart @@ -81,7 +81,7 @@ class ContextBuilderImpl implements ContextBuilder { } byteStore ??= MemoryByteStore(); - performanceLog ??= PerformanceLog(StringBuffer()); + performanceLog ??= PerformanceLog(null); if (scheduler == null) { scheduler = AnalysisDriverScheduler(performanceLog);