Skip to content
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

dart.exe eating all memory #40243

Closed
inohunk opened this issue Jan 21, 2020 · 47 comments
Closed

dart.exe eating all memory #40243

inohunk opened this issue Jan 21, 2020 · 47 comments
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P1 A high priority bug; for example, a single project is unusable or has many test failures

Comments

@inohunk
Copy link

inohunk commented Jan 21, 2020

When i try to run flutter app in following ide(Android Studio or Visual Studio Code) the dart.exe process is created in the Task Manager(I use windows 10 Pro) and eats up all the RAM(32GB).
I think this is related to the Dart Analysis server, since when I kill the dart process that eats up all the memory in Android Studio displays the message 'Analysis server has terminated'. This process fills RAM at a speed of ~150 MB per second. Note that usually exists several processes dart.exe, but only one of them for some reason eats all the RAM. Please, fix it.

@masonzhang
Copy link

masonzhang commented Feb 22, 2020

This happens frequently when I checked the "Enable Hot UI" from settings - Languages & Frameworks -> Flutter on Android Studio.

@mraleph mraleph added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Feb 25, 2020
@mraleph
Copy link
Member

mraleph commented Feb 25, 2020

/cc @devoncarew seems like a bug around analysis server memory consumption. I don't know if there is anything users can do to diagnoze?

@devoncarew
Copy link
Member

@inohunk and @masonzhang - can you share the version of the Dart SDK that you're running? From dart --version or flutter --version; thanks.

@stereotype441
Copy link
Member

@inohunk and @masonzhang - in addition to the version of the Dart SDK, it would be useful to get some info from the analyzer diagnostics web page. You can see this info by clicking on the gear icon at the left edge of the "Dart Analysis" tab and selecting "view analyzer diagnostics":
image

Once you've opened the diagnostics page, click on "Contexts" and you should see a page with a tab for each analysis context. make sure that the "Context location" shown for each of the context tabs is a place where you actually expect to see Dart code. (Something that occasionally goes wrong for some users is that they have accidentally configured their IDE in a way that causes it to try to analyze a very large number of files, for example by pointing it to the root of their home directory).

Let us know what you find out and then we can help troubleshoot further.

@stereotype441 stereotype441 added the P1 A high priority bug; for example, a single project is unusable or has many test failures label Feb 25, 2020
@masonzhang
Copy link

@stereotype441 thanks a bunch for your feedback. my "flutter --version" command output is as following:

Flutter 1.14.6 • channel beta • https://github.com/flutter/flutter.git
Framework • revision fabeb2a16f (4 weeks ago) • 2020-01-28 07:56:51 -0800
Engine • revision c4229bfbba
Tools • Dart 2.8.0 (build 2.8.0-dev.5.0 fc3af73)

I viewed my analyzer diagnostics, and on here are some information for "Context files":

  • Priority files: 1
  • Added files: 49
  • Implicit files: 988 (dart libraries and my plugin libraries)

and nothing special on diagnostics page.

In addition, this happens on my web project with the "Enable Hot UI" from settings checked. I can reproduce this by keeping change code and save.

dart-bot pushed a commit that referenced this issue Feb 28, 2020
R=brianwilkerson@google.com, paulberry@google.com

Bug: #40243
Change-Id: Iecd2a0bd4053588dfb93445918656df65bf4b60e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137738
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
@scheglov
Copy link
Contributor

We found an issue that might be the one causing memory leak when Hot UI is enabled.

This CL https://dart-review.googlesource.com/c/sdk/+/137738 fixes it in Dart SDK, eventually it will percolate to Flutter.

@scheglov scheglov self-assigned this Mar 3, 2020
@scheglov
Copy link
Contributor

scheglov commented Mar 6, 2020

The fix landed as 3cf8c3d, and available with Dart SDK 2.8.0-dev.12.0 and 2.8.0-dev.11.0. The current master channel of Flutter uses Dart 2.8.0 (build 2.8.0-dev.12.0 9983424a3c), please try the version of Flutter that has the fix and report if you still experience the memory issue.

@jcollins-g
Copy link
Contributor

@inohunk and @masonzhang , have you had a chance to try and reproduce this with a newer version of Flutter as indicated above?

@masonzhang
Copy link

masonzhang commented Mar 17, 2020

currently I'm using the beta version. I'll keep you updated once I have tested it. Thanks a lot!

@jcollins-g
Copy link
Contributor

Thanks @masonzhang. Closing for now, but please reopen if you continue to have issues.

@yintaibing
Copy link

yintaibing commented Apr 7, 2020

I was troubled with this issue since last week, even after upgraded the latest flutter version.
It happens when use flutter run command, but doesn't happen when use flutter build command.
My "flutter --version" command output is as following:

Flutter 1.18.0 • channel dev • https://github.com/flutter/flutter.git
Framework • revision de1e572916 (8 hours ago) • 2020-04-06 16:15:07 -0700
Engine • revision df257e59c2
Tools • Dart 2.8.0 (build 2.8.0-dev.20.0 1210d27678)

Plz fix it...

Update 1: use VS Code to run is OK, but use Android Studio would happen.
Is this more likely a problem of the Android Studio Dart/Flutter plugin?

Update 2: Sadly, today, I use VS Code to run, this issue also happens...

@jcollins-g jcollins-g reopened this Apr 7, 2020
@stereotype441
Copy link
Member

Looking at our internal benchmarks (golem benchmark analysis-server-cold-memory) I see a 75-80% spike in analysis server memory usage at bac08fb, which is included in 1210d27 (the version @yintaibing reported).

@scheglov has been trying to reproduce the memory usage spike locally and hasn't had any luck so far. @sortie can you help?

@fluttdev
Copy link

Same problem here.

[√] Flutter (Channel dev, v1.18.0-dev.5.0, on Microsoft Windows [Version 10.0.18363.720], locale de-DE)
    • Flutter version 1.18.0-dev.5.0 at C:\src\flutter_windows_v1.9.1+hotfix.5-stable\flutter
    • Framework revision 7f56b53de4 (2 days ago), 2020-04-12 12:00:01 -0400
    • Engine revision beb8a7ec48
    • Dart version 2.8.0 (build 2.8.0-dev.20.0 89b0f67261)


[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at C:\Users\pschu\AppData\Local\Android\Sdk
    • Platform android-29, build-tools 29.0.2
    • ANDROID_HOME = C:\Users\pschu\AppData\Local\Android\Sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
    • All Android licenses accepted.

[√] Android Studio (version 3.6)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

image

@jcollins-g
Copy link
Contributor

Just a quick update to let users know we are still interested in pursuing this, and have someone who should be able to work on it soon.

@sortie
Copy link
Contributor

sortie commented Apr 24, 2020

An analysis server memory issue was fixed in 838b2ec. Does that fix this issue?

@scheglov
Copy link
Contributor

We fixed one issue that you have caused higher memory usage than necessary in 838b2ec. However because we cannot reproduce this issue per se, we cannot be sure if the fix helps here. Eventually the change will get to Flutter and might help, or not.

@xiaxiayige
Copy link

xiaxiayige commented Apr 25, 2020

what happend ???

I only run https://github.com/flutter/gallery

TIM图片20200425111236
TIM图片20200425091650

@sebe
Copy link

sebe commented Apr 25, 2020

Hey @xiaxiayige Dart on Flutter master and dev have been update to 2.9.0-3.0.dev, for me on linux,
maybe that fix mentioned above is in there and it's now worth having another look.

Flutter 1.18.0-9.0.pre.12 • channel master • https://github.com/flutter/flutter.git
Tools • Dart 2.9.0 (build 2.9.0-3.0.dev 94178e9)

Flutter 1.18.0-8.0.pre • channel dev • https://github.com/flutter/flutter.git
Tools • Dart 2.9.0 (build 2.9.0-3.0.dev b0d3585)

@xiaxiayige
Copy link

Hey @xiaxiayige Dart on Flutter master and dev have been update to 2.9.0-3.0.dev, for me on linux,
maybe that fix mentioned above is in there and it's now worth having another look.

Flutter 1.18.0-9.0.pre.12 • channel master • https://github.com/flutter/flutter.git
Tools • Dart 2.9.0 (build 2.9.0-3.0.dev 94178e9)

Flutter 1.18.0-8.0.pre • channel dev • https://github.com/flutter/flutter.git
Tools • Dart 2.9.0 (build 2.9.0-3.0.dev b0d3585)

Thank you, I have updated, but still the same result

@Profesor08
Copy link

Profesor08 commented Apr 26, 2020

Just now i had this issue in flutter app. And it happened after deleting an asset, from assets folder. Was an error of missing asset, I have replaced in code with another one, but error didn't gone. I restarted project and from that moment dart started to eat all available memmory. I tryed to fix with restarting ide, pc, rebuilding app, but nothing helped.
The only one way was is to delete all project and create new one, keeping lib/ and pubspec.yaml
Flutter is on current master branch

@alexpavelm
Copy link

Had the same issue, fixed it by running flutter clean.

@scheglov
Copy link
Contributor

Observatory recently added a way to get heap dumps and load them later. So, if you have an issue with continuing heap growth, please make such heap dump, archive it, and share with me. The file will be most probably too big to email it, so consider using Google Drive.

  1. Configure IntelliJ to run DAS with Observatory enabled.
    1.1. Press Shift twice quickly to open the search dialog.
    1.2. Type Registry...
    image

1.3. In the Registry dialog find dart.server.vm.options and add --observe:5000 --disable-service-auth-codes. Note, that with the last option any process on your machine can connect to the Observatory, so remove both options after making the heap dump for better security.
1.4. Restart the Dart Analysis Server.
image

  1. Reproduce the heap growth situation and get the heap dump.
    2.1. Wait until DAS started and done initial analysis.
    2.2. Do things that you observed cause significant growth of consumed memory and observe it using your favorite operating system monitoring tool.
    2.3. Once you see some significant memory usage, connect to Observatory, http://127.0.0.1:5000/. You will see something like this:
    image
    2.4. You need the other isolate, not _cacheCleanUpFunction. It should have a significant number for its heap. For me the whole dart process is reported to have 2.05GB, and the isolate 1.3GB.
    image
    2.5. Click heap snapshot.
    2.6. It will take long time to get the snapshot and analyze it. But eventually you will get something like this:
    image
    2.7. You need the Save button in the top-right corner. Press it, Observatory will download the file with some default name.

  2. Share the file with me: scheglov@google.com
    3.1. Please archive it, it will get about 5 times smaller.
    3.2. I will use this file only to analyze the heap usage, and delete it once done.

@Ostapenko-Yura
Copy link

Ostapenko-Yura commented May 7, 2020

Faced same problem today using Android Studio.

image

This memory consuming process is created right after I do "run".

I did #40243 (comment) but it seems to be not a Dart Analysis Server, because in my case I see that Analysis Server is ok and tooks ~200mb.

I tried switching to

  • dev (flutter version 1.18.0-13.0.pre, tools and dart 2.9.0<build 2.9.0-5.0.dev 4da5b40>)
  • master (flutter version 1.18.0-14.0.pre.4, tools and dart 2.9.0<build 2.9.0-5.0.dev 4da5b40>)
  • stable (flutter version 1.17.0, tools and dart 2.8.1)
    reinstalled flutter SDK but nothing helped.

@ghost
Copy link

ghost commented May 8, 2020

I had this problem and I solved it with a rather weird workaround.
If you run the App normally the same bug will occur however if you run "profile" button which is located in the right of run button(in android studio) your dart.exe will work fine.
After doing this,run the app normally and you'll see your dart.exe will run fine without becoming too big.
MIne consumes almost 380 Mb of Ram
asd

@scheglov
Copy link
Contributor

scheglov commented May 8, 2020

@jacob314 @johnniwinther It looks like it might be an issue in the flutter process, not sure if something related to compilation to kernel or instrumentation.

@shinayser
Copy link

shinayser commented May 8, 2020

WOW my computer is crashing a LOT after flutter 1.17 update. I just figured out that the "dart"process under Task Manager was consuming 10gb of ram!!! (my laptop has only 16)

UPDATE: I did a Flutter Clean and now seems to be fixed.

@GitDoGui
Copy link

GitDoGui commented May 9, 2020

OMG, dart.exe consumed more than 10gb of my RAM.
I ran the command flutter clean and it seems to be fixed.

@ShivamGoyal1899
Copy link

ShivamGoyal1899 commented May 10, 2020

Had the same issue, dart.exe consuming around 6-7 Gigs RAM. Doing a flutter clean worked fine.

Update: the issue is back again

@defemz
Copy link

defemz commented May 11, 2020

I experienced the same issue. a Dart process consumed more than 7gb of my total 8gb memory after i upgraded flutter to version 1.17.0. However as suggested earlier by others, flutter clean seems to fix the issue.
Edit: The issue came back

@jensjoha
Copy link
Contributor

In the Windows Task Manager, as I recall, one can right-click on the columns and say something like "select columns" -- this gives a check box list that contains an entry like "command" or "command line" or similar. Checking that (and presing ok etc) should give another column with the full command used to create the dart process which would could probably help narrow down which dart process is actually to blame.

@defemz
Copy link

defemz commented May 11, 2020

I experienced the same issue. a Dart process consumed more than 7gb of my total 8gb memory after i upgraded flutter to version 1.17.0. However as suggested earlier by others, flutter clean seems to fix the issue.

Contrary to my earlier observation that running flutter clean resolved memory consumption issue by dart process. Flutter clean does not offer lasting solution to this problem. The issue came up again, t Anyone with a better solution?

@jensjoha
Copy link
Contributor

@defemz if you are currently facing this issue, could you try out what I suggested above so we can figure out which exact sub-process it is, using all that memory?

@HryhoriiZiahun
Copy link

HryhoriiZiahun commented May 11, 2020

Same issue
any solutions?
image

command line

image
image

@jcollins-g
Copy link
Contributor

@HryhoriiZiahun @defemz @ShivamGoyal1899

To echo @jensjoha's comment, it's most helpful for the team to know exactly which subprocess is consuming memory. If it isn't the dart analyzer we'll need to open other bugs and alert other project teams to these problems.

@defemz
Copy link

defemz commented May 12, 2020

@HryhoriiZiahun @defemz @ShivamGoyal1899

To echo @jensjoha's comment, it's most helpful for the team to know exactly which subprocess is consuming memory. If it isn't the dart analyzer we'll need to open other bugs and alert other project teams to these problems.

I have pinpointed the dart process causing the unacceptable high RAM consumption. Attached is the process as shown in Windows 10 Task manager. The highlighted entry is the culprit process:
image

@HryhoriiZiahun
Copy link

and how we can fix this?

@mraleph
Copy link
Member

mraleph commented May 12, 2020

Let's fork this issue because it is a different issue.

@mraleph
Copy link
Member

mraleph commented May 12, 2020

Filed separate issue #41862 now that we know that it is not analyzer (which is what this issue was originally about).

@jensjoha
Copy link
Contributor

If anyone can provide reproduction (in #41862) that would be great.

@alen252
Copy link

alen252 commented May 25, 2020

How can i fix this problem.

@GitDoGui
Copy link

How can i fix this problem.

@alen252 try flutter clean

@defemz
Copy link

defemz commented May 25, 2020

How can i fix this problem.

@alen252 try flutter clean

flutter clean is not a permanent solution. With version 1.17.0, build takes much longer and flutter clean mostly solve for current build and not necessarily subsequent builds.

@mohanadshaban
Copy link

How can i fix this problem.

@alen252 try flutter clean

flutter clean is not a permanent solution. With version 1.17.0, build takes much longer and flutter clean mostly solve for current build and not necessarily subsequent builds.

Yes, Same Issue and yet no permanent solution only going back before 1.17 update 🙁

@RaghuMudem
Copy link

Had the same issue, fixed it by running flutter clean.

Perfectly worked. I have wasted lot of time to upgrade android and flutter sdk's but noting worked. After i executed, 'flutter clean' which saved my day.

@DevarshRanpara
Copy link

I am on flutter version 1.7.1 on stable channel.
Same story for me. dart.exe consumes full memory and my PC stop responding.
Always i need to flutter clean before every run, and that is not a solution.

@NeelakandanKannan
Copy link

I am also facing this issue. dart.exe takes large memory. So, PC is not responding.

@mraleph
Copy link
Member

mraleph commented May 29, 2020

I am locking this thread to prevent unrelated "me toos". The work on this problem is tracked in these two issues:

If the problem you have is dart.exe suddenly allocating a lot of memory and forcing you to reboot you can apply this workaround for now.

@dart-lang dart-lang locked as resolved and limited conversation to collaborators May 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P1 A high priority bug; for example, a single project is unusable or has many test failures
Projects
None yet
Development

No branches or pull requests