Analyzer memory usage is much higher with a clean cache #51127
Labels
analyzer-stability
area-analyzer
Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
P2
A bug or feature request we're likely to work on
type-performance
Issue relates to performance or code size
Via #41793 (comment) I found and checked out https://github.com/kodecocodes/rwf-materials.git and opened the entire directory (after running
flutter pub get
500+ times --- I don't know if there's a helper command but that's what I did anyway).When opening with a clean cache (i.e.
rm -rf ~/.dartServer/.analysis-driver/
) it ends up using ~14GB of ram. Closing my editor and opening it again it "only" uses ~5GB.A "hack" is to create and delete a file (which might have to be from the command line) which causes
clearLibraryContext()
to be called which makes - at least from the used heap perspective - the memory to go down a lot (from ~13.5GB to ~3.5GB) (#51126 about why the heap isn't reduced).It can't just be called all the time though (e.g. I tried running it after analysis was done (i.e. when
transitionToIdle
) but that maded for instance go to definition not work because either_priorityResults
was now not really valid anymore (that should probably be cleared inclearLibraryContext()
too), or the file that was just analyzed was just made invalid because it transition to idle after having analyzed it...I don't know if there's a "safe" time to run it. Even if there is, it feels like sort of a hack --- it feels like there's a "leak" of sorts via
AnalysisDriver._libraryContext
->LibraryContext.elementFactory
-> (LinkedElementFactory._libraryReaders
andLinkedElementFactory.rootReference
) that should be fixed instead.I'll keep looking, but I'm guessing others have more insight than I do there.
/cc @scheglov
The text was updated successfully, but these errors were encountered: