Dart Analyzer's Memory Bugs: Double Parsing, Cache Invalidation, and a 11.6 GB Monorepo Isolate
Large Flutter projects with analyzer plugins can see RAM spikes from 2.7 GB to 4.0 GB, CI `dart analyze` runs jump from 2.4 seconds to 15, and macOS crashes with `Code Signature Invalid` when two SDKs share plugin cache. Teams on big repos or multiple worktrees should count analyzer memory before blaming their IDE or AI agents.
Dart Analyzer's plugin and cache layers are leaking memory and burning CPU in large Flutter projects. Multiple open GitHub issues show the same Library being parsed twice because the plugin cache only keeps priority files, the analyzer re-linking 729-Library cycles on every startup because deserialization records an opaque API dependency, and plugins lacking persistent disk caches so CI redoes the entire semantic setup each run. One monorepo case with 14,000 Dart files and 45 analysis contexts jumps from 0.19 GB to 11.6 GB when a plugin is pointed at the repo root instead of a single package; two plugins put the process at 34 GB.
The failures compound with AI agents and multiple Git worktrees, where memory is already tight. The plugin execution alone shows the cost: in a 15-second `dart analyze --fatal-infos` run, reading and parsing 6697 files uses 4.3 seconds, linking 3359 Library cycles uses 5.4 seconds, fine-grained dependency computation 2.6 seconds, and Riverpod rule execution only 0.1 seconds. On macOS, two projects with different Dart SDKs can share the same plugin `.aot` cache file and crash with `Code Signature Invalid`. Fixes exist: a recent patch cuts `analyzeFile` calls from 1330 back to 665 by adding an 8-entry cache for non-priority libraries, but the deeper issues around cache invalidation and plugin isolation remain.
Analyzer plugins are expensive not because of the lint rules but because each plugin isolate rebuilds the entire semantic analysis, including reading files, linking, and computing dependency summaries, for every run. The rule execution itself is negligible.
The cache invalidation bug is a feedback loop: the analyzer records an opaque dependency while deserializing its own cache, so the next startup rejects that cache and rebuilds, recording again. This turns a one-time API change into permanent re-linking.
These issues share a design assumption that analyzer runs happen in an IDE with a priority file set, not in CI or across a monorepo. When the analysis root is a workspace, the plugin treats it as if it needs everything, and memory scales linearly with repo size. That assumption is breaking as Flutter projects grow and more tools invoke analyzers headlessly.