Skip to content

AnalysisDriverScheduler retains events if there is no subscriber #61165

@davidmorgan

Description

@davidmorgan

Investigating a memory leak in build_runner, dart-lang/build#4025, I tracked one part of the problem down to AnalysisDriverScheduler.

It has a stream of events; if nothing subscribes to the stream, they are just retained as long as the AnalysisDriverScheduler is retained.

Of course a workaround is to drain the stream. Because build_runner doesn't actually have access to the scheduler, that needs an analyzer change: https://dart-review.googlesource.com/c/sdk/+/441740 ... I checked that this works by copying build_resolvers.dart into the build_resolvers package, but it's probably better to leave it in analyzer for now.

Follow-up:

  • Would it be possible to backport the "drain" fix to a version 7 release?
  • I wonder if there is a better default behaviour here--do clients usually need that events are retained until three is a subscription?
  • It may be worth checking other places the analyzer is integrated for the same problem. I checked a couple of places in google3 (summary computation, codegen), they don't have a leak because they recreate AnalysisDriverScheduler on every action.

Metadata

Metadata

Assignees

Labels

area-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.model-performancePerformance/memory issues in analyzer/cfe

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions