sdk icon indicating copy to clipboard operation
sdk copied to clipboard

DotNet 6 on Mac M1 - high CPU use and processes stuck

Open eighteentee opened this issue 2 years ago • 47 comments

Description

I have just started coding with DotNet on my Mac as part of a CS degree course. I am experiencing a weird problem when running simple projects either in VS2022 (preview for Mac), Rider or VS Code. I first noticed that battery life was draining fast and checked the Activity Monitor - there were a number of DotNet processes all pegged at 100%. Basically if I run projects then these processes seem to run away and never quit even though a project is stopped in whatever IDE I am using - each time I must manually force quit the processes in Activity Monitor. It's getting to be really annoying now.

Configuration

I am running the latest release of DotNet 6.0 on MacOS 12.01 on a MacBook Pro Max M1 with 10 cores, 32 GPU cores, 32gb RAM and 1tb SSD. I am trying to work with simple Razor Pages apps.

eighteentee avatar Dec 03 '21 07:12 eighteentee

I have same problem

hvkhoi avatar Dec 05 '21 07:12 hvkhoi

I also have the problem that the arm version seems to be unable to stop the processes and also repeats them several times. This is the usage of CPU processing after executing the command "dotnet run " image

hasanxdev avatar Dec 08 '21 11:12 hasanxdev

same to me. any fix yet?

jun92 avatar Dec 13 '21 15:12 jun92

No fix as yet. It's starting to become unusable on my machine. Hopefully MS see this and fix it soon. Can't even run VS2022 in a virtual machine as it is so slow!

Incidentally, VS2022, VS2019, VSCode (with C# DotNet extensions) and JetBrains Rider all exhibit the same problem and allow native DotNet 6 processes to accumulate and run away at 100% CPU use all the time. Having to constantly keep my eye on Activity Monitor just to close down these DotNet 6 processes is becoming tiresome and cumbersome. This is almost at the point where I'm going to have to buy a Windows machine just to work with DotNet 6 - bonkers when I have such a powerhouse of a laptop!

Is there any way of moving this up the priority list for fixing? Surely just cannot be a few people experiencing this same problem?

eighteentee avatar Dec 13 '21 15:12 eighteentee

This is not isolated to M1 Macs. I'm having the same problem on a 2016 i7 MBP. I haven't isolated the exact steps to reproduce yet. I'm using VSCode 1.63.2 and .NET 6.0.101. The runaway processes either need to be quit through Activity Monitor, or the laptop needs to be rebooted. They won't go away on their own even after VSCode, terminal, etc are closed.

brianamm avatar Jan 04 '22 18:01 brianamm

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

Hey folks, in order to help us diagnose this it would be very helpful if you could provide some of the commands that these dotnet processes are running. I think it's possible to do this through Activity Monitor, but you should also be able to use the ps utility to retrieve some of this. If we had an idea of what commands/applications were being run via the dotnet host, we could triage further.

baronfel avatar Jan 05 '22 19:01 baronfel

This affects me as well.

Command: dotnet run in new c# console app, then ctrl-c to quit

lsof Screen Shot 2022-01-07 at 2 38 24 PM

ps -ef | grep 6687

daniel@Magneto ~ % ps -ef | grep 6887
  501  6887     1   0  6:18PM ??         0:27.30 dotnet tool run dotnet-interactive -- notebook-parser
  501  6892  6887   0  6:18PM ??         2:39.16 /usr/local/share/dotnet/dotnet /Users/daniel/.nuget/packages/microsoft.dotnet-interactive/1.0.260601/tools/net6.0/any/Microsoft.DotNet.Interactive.App.dll notebook-parser

Not sure why dotnet-interactive is in the mix, or notebook-parser since this is not a "notebook" or "interactive" - It's just a regular console app.

daniel-packard avatar Jan 07 '22 20:01 daniel-packard

Same issue, on macOS Big Sur (11.6.2). Using dotnet 6.0.101 and commit ef49f6213a. image

A single dotnet process uses 100% CPU and doesn't get below 96%. If I spin up another dotnet process at the same time, the same issue all dotnet processes sit around 99% CPU. image

Bryke-Angar avatar Jan 11 '22 15:01 Bryke-Angar

Happens with dotnet 5.0 as well...

image

I'm using Visual Studio 8.10, I though I was the only one...

LeonSolisPedro avatar Jan 12 '22 04:01 LeonSolisPedro

I just started my macbook i7 and I noticed my fan very active and the battery draining quick. I saw I had multiple processes of dotnet at 99% of CPU. I killed all of them.

carmonac avatar Jan 14 '22 09:01 carmonac

Does anyone have a workaround for this? I can't keep having to check Activity Monitor every time I run my apps to check stuff just to close these rogue DotNet processes. Every. Single. Time. It's really getting old now 😞

eighteentee avatar Jan 15 '22 17:01 eighteentee

do you have vscode with C# extension? I noticed that removing that extension it solved the problem.

carmonac avatar Jan 27 '22 12:01 carmonac

For me, this originated from the C# extension for VS Code when trying to start a .NET Interactive notebook. Even after closing all instances of VS Code, the botnet process persisted. The quick fix for now is to just kill the process.

Edit: This was not on an M1 MacBook, but an intel MacBook. (a 2019 13' MacBook Pro to be precise)

jakob753951 avatar Feb 04 '22 14:02 jakob753951

I have the same problema when I run VSCode for Mac with m1 running a dotnet project and close it. Always 2 dotnet6 processes remains with 100% of CPU consumption . I tried upgrade the OmniSharp extension to a m1 support, but the problem still occur.

ArquitetoMovel avatar Feb 06 '22 20:02 ArquitetoMovel

So this requires VS Code to repro? If you disable omnisharp and all other extensions does it still repro?

What are the command lines of the errant processes?

If you attach a debugger what is the stack of the busy thread?

danmoseley avatar Feb 06 '22 22:02 danmoseley

Can confirm that disabling all MS C# extensions in VS Code eradicates the problem.

eighteentee avatar Feb 06 '22 22:02 eighteentee

Can you enable one at a time to help find the culprit? Then we should move this issue there

danmoseley avatar Feb 06 '22 23:02 danmoseley

The issue seems to stem from the extension ".NET Interactive Notebooks" There is already an issue on the GitHub of that extension: https://github.com/dotnet/interactive/issues/1650

jakob753951 avatar Feb 11 '22 14:02 jakob753951

Definitely not ".NET Interactive Notebooks" for me as I don't have that extension installed. Similar to many other people here, I do have the C# extension installed. While I have yet to pinpoint the exact steps to reproduce, this problem definitely occurs when I'm working on C# console apps.

BD5WP avatar Feb 11 '22 14:02 BD5WP

If it's the C# extension this should be tracked in the Onnisharp repo.

danmoseley avatar Feb 11 '22 14:02 danmoseley

Definitely not ".NET Interactive Notebooks" for me as I don't have that extension installed. Similar to many other people here, I do have the C# extension installed. While I have yet to pinpoint the exact steps to reproduce, this problem definitely occurs when I'm working on C# console apps.

That's certainly interesting, as I don't have the C# extension installed, but only the Python, Jupyter, and ".NET Interactive Notebooks" extensions installed

jakob753951 avatar Feb 11 '22 14:02 jakob753951

Perhaps both the extensions are doing a similar thing wrong? Or the issue really is from the dotnet sdk.

jakob753951 avatar Feb 11 '22 14:02 jakob753951

Pretty sure is dotnet sdk

LeonSolisPedro avatar Feb 11 '22 14:02 LeonSolisPedro

Perhaps both the extensions are doing a similar thing wrong?

Certainly possible, but...

Or the issue really is from the dotnet sdk.

...seems more likely.

BD5WP avatar Feb 11 '22 14:02 BD5WP

After the latest update, I can't see 100% CPU dotnet process anymore after close vscode.

ArquitetoMovel avatar Feb 13 '22 23:02 ArquitetoMovel

Interesting. I assume you mean an update to .NET 6? Does 6.0.2 fix it for others? There were a number of fixes, none obviously connected, but conceivably connected perhaps

danmoseley avatar Feb 14 '22 00:02 danmoseley

Same issue here! Visual Studio 2019 MacOS, Running an mcv web app (dotnet 5) for a school project. My system: core i9, 64gb ram, 2tb ssd. My laptop just takes off the fans are at full rpm constantly. I never had this issue with web API projects. The process named dotnet uses 250% CPU and when i stop running the program, the process stays alive and keeps using 250% CPU.. Really weird issue and annoying too. Sometimes it jumps to 550% CPU. How is that even possible.

seanpaulharsevoort avatar Mar 29 '22 14:03 seanpaulharsevoort

Macbook Pro - M1 Pro CPU Visual Studio Mac 8.10.21 (Build 4)

Same issue. I get a hung dotnet process typically running around 180% cpu. Been happening for months. Several updates have been released and this issue remains.

If I could run Windows through bootcamp I would, VS for Mac is terrible.

DarinFlippo avatar Apr 07 '22 19:04 DarinFlippo

@jonsequitur there seems to be a problem with runaway CPU related to .NET interactive notebooks on Mac. Do you have any context here, and can you help with next steps?

danmoseley avatar Apr 07 '22 20:04 danmoseley