sdk
sdk copied to clipboard
DotNet 6 on Mac M1 - high CPU use and processes stuck
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.
I have same problem
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
"
same to me. any fix yet?
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?
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.
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.
This affects me as well.
Command:
dotnet run
in new c# console app, then ctrl-c
to quit
lsof
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.
Same issue, on macOS Big Sur (11.6.2). Using dotnet 6.0.101 and commit ef49f6213a.
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.
Happens with dotnet 5.0 as well...
I'm using Visual Studio 8.10, I though I was the only one...
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.
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 😞
do you have vscode with C# extension? I noticed that removing that extension it solved the problem.
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)
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.
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?
Can confirm that disabling all MS C# extensions in VS Code eradicates the problem.
Can you enable one at a time to help find the culprit? Then we should move this issue there
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
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.
If it's the C# extension this should be tracked in the Onnisharp repo.
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
Perhaps both the extensions are doing a similar thing wrong? Or the issue really is from the dotnet sdk.
Pretty sure is dotnet sdk
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.
After the latest update, I can't see 100% CPU dotnet process anymore after close vscode.
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
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.
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.
@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?