-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Analyzer uses too much memory when there is many lints enabled #41793
Comments
Same with me I encountered this bug after I upgraded to flutter 1.17.0 which has Dart 2.8.1... I redownloaded the Flutter v1.12.13 w/c has Dart v2.7.0.....and everything backs to normal......PLEASE FIX THIS ASAP!!!!! |
So lets vote the issue so that it gets more atention. |
The way it happens to me is when I start typing I fix it by terminating dart process from task manager and starting it again. but this is really getting annoying. since i can't type here is an example code where this bug shows itself : @RestApi(baseUrl: APP_BASE_URL)
abstract class RestClient {
factory RestClient(Dio dio, {String baseUrl}) = _RestClient;
@GET('/courses')
Future<List<Course>> getCourses();
@GET('/trainers')
Future<List<Trainer>> getTrainers();
@POST('/signup')
Future<HttpResponse<void>> signup(@Body() Map<String, dynamic> json);
@POST('/login')
Future<HttpResponse<User>> login(@Body() Map<String, dynamic> json);
@POST('/users/avatar')
Future<User> addUserAvatar(@Body() Map<String, dynamic> json);
} note : and I don't even to run my code it just happens when I type flutter doctor report:
here is my pubspec.yaml:
|
So.. is this issue responsible for my Dart process eating over 18GB of RAM? It only happens after a few hours. #44792 |
Is this related to flutter/flutter#90868? |
This is still a big issue. Our project with many packages consistently uses more than 10GB of ram. |
Sorry this is still an issue for you @leisim. Are you using dart_code_metrics? |
@pq no, just the default flutter lints. The big issue is the number of packages in the workspace. With a VSCode workspace that only includes some of the packages, the ram usage can be reduced significantly. But it's certainly not ideal 😔 |
@pq any updates or workarounds here? This issue is getting worse and slowing down our entire team 😔 |
@scheglov has been looking at element model memory usage and summary serialization but I don't know if anything conclusive has come out of it. We're also looking at leveraging some work on leak detection that @polina-c is driving but that's early yet. TL;DR nothing substantial yet but folks are looking... thanks for your patience @leisim and sorry for the inconvenience! |
Let us know if you need a sample project to reproduce the issue |
A repro would be fantastic. Thanks @leisim! |
TIL Clickup uses Flutter |
Is it possible to disable Dart Analysis in IDE at least? |
If you're asking whether the tool currently supports having different analysis options in IDEs and the command-line, the answer is 'no'. If you're asking whether it's possible to not run the analysis server in an IDE, the answer is 'yes', but you'll loose all of the language support: semantic highlighting, code completion, hovers, searches, everything. If you're asking whether it's possible to stop running lints, both in the IDE and on the command-line, then the answer is 'yes'. You can disable lints in your local analysis options file even if they were enabled in an included options file. |
@bwilkerson Thanks for you answer. I was asking about stopping analysis in IDE but can't find the option to turn it off.
Does it mean that I simply should disable Dart support in IDE? Seems that it's not what I want. I thought that I could turn linting off in IDE, and it would help me to save RAM on my laptop then. |
You can't turn linting off in the IDE without turning it off everywhere, but you can disable any (or all) of the lints that you want to through the analysis options file. See https://dart.dev/guides/language/analysis-options#disabling-individual-rules for details. |
Bad news. :( I still need to lint the source code in CI... Thanks anyway. |
Sorry for the continued trouble @vasilich6107. A few things of note for anyone digging into this:
I'd be curious how different the memory profile looks like w/o lints enabled. (And if you've noticed any that seem to impact memory in particular, that'd be especially interesting.) I'd also expect the biggest drop if you disabled Is this an open source project? |
Yeah, any chance flutter/flutter#95092 and #48925 could be addressed sooner? Coz the problem is literally "by design" and not by how the plugin code is written |
I'm working on some perf improvements for a handful of lints that use a utility method that's problematic (#58890). Hopefully this will help. In the meantime, I'd be curious to know if any lints in particular are especially impacting. One I'm particularly curious about is |
with this repo: https://github.com/kodecocodes/rwf-materials.git |
@hongfeiyang are you opening the whole folder in VS Code? If yes - is this intentional, why not open a specific subfolder instead? /cc @jensjoha |
Oh yea, I was being lazy and should have opened a single sub directory only. Thanks for pointing that out, it only takes around 700MB RAM to analyse a single sub directory. |
Possibly related: |
I just wanted to chime in after coming back from the long weekend and wondering what was chomping all my memory causing instability in other apps and found this little gremlin. It is not often you come across something more resource intensive than a chromium process but this process certainly wants to make itself known to be a competitor. $ ps -e -orss=,args= | sort -nr | head
4857356 /home/loki/projects/flutter/bin/cache/dart-sdk/bin/dart language-server --client-id=Android-Studio --client-version=AI-222.4459.24 --protocol=analyzer |
Sorry that everyone here is experiencing high memory usage by the Dart Analysis Server (DAS). After reviewing all of the comments above, I don't see any evidence that enabling many linter rules results in much higher memory usage. If you are just experiencing high memory usage by DAS, feel free to open a separate issue, if you can follow up with repro steps and more information. Some basic info we would need:
If you believe that enabling many linter rules is the cause of high memory usage, we'll need some evidence of that. In particular, if you see high memory usage, and then disable all linter rules, and then restart DAS and check the new memory usage, this is not a great test 😄 . A long-running process will likely consume more memory than a fresh one, due to caches filling with info, leaks, etc. I think a few trials, flipping linter rules on and of and on and off, would be required. |
I'll just note that it's also possible, given what little we know about the cause at the moment, that it isn't the number of lints, but a small number of lints that are not well behaved in terms of memory use. (We have tried to find problematic code, but haven't found anything obvious.) If you can reliably reproduce the memory problems it would be interesting to try to narrow down whether there are a small number of lints that need to be tuned or whether it really is the number of lints. And if it is the number of lints, is the memory usage linear, exponential, etc. |
I'm closing this issue as a few folks on the Dart team have landed many memory improvements in the Analyzer code bases over the last year (see below). I won't promise that your memory problems are solved, but I think at this point, it would be most effective to sort of rebase the discussion. Anyone experiencing similar "giant memory usage" issues with the Dart Analyzer, and you'd like to document a bit your situation, also please follow these instructions: First, be sure to bump to the latest Dart, 3.2.0, as it has some performance improvements over 3.1.0. Then, if you experience what you feel is an inordinate amount of memory being used (we don't have any SLOs yet in this space, but anything north of 5GB is probably noteworthy):
Recent memory-reducing changes:Dart ~ 2.19.0, Jan 2023
Dart ~3.0.0, May 2023
Dart ~3.1.0, August 2023
Dart ~3.2.0, November 2023
(There were also speed-up improvements made in this time frame, and improvements to our analytics, logging, benchmarking, and platform coverage, but I'm not documenting those here on this memory-focused issue.) |
The Dart Analyzer is taking 1,811.0MB of RAM when I have 125 lint rules enabled in
analysis_options.yaml
. After removing the 125 lint rules the memory usage decreased to 450MB (max).The lint rules that I had enabled in analysis_options.yaml file are:
analysis_options.yaml
The text was updated successfully, but these errors were encountered: