-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Reduce allocation in Process.GetProcessesByName #68705
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
Conversation
|
Tagging subscribers to this area: @dotnet/area-system-diagnostics-process Issue DetailsGetProcessesByName is loading all of the information for every process found, even if it'll immediately be thrown away because the name doesn't match. [Benchmark]
public void GetProcessesByName()
{
foreach (Process p in Process.GetProcessesByName("dotnet.exe"))
p.Dispose();
}
|
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.FreeBSD.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.UnknownUnix.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Win32.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Win32.cs
Outdated
Show resolved
Hide resolved
ff26db4 to
880c8b3
Compare
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Linux.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.OSX.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.BSD.cs
Outdated
Show resolved
Hide resolved
GetProcessesByName is loading all of the information for every process found, even if it'll immediately be thrown away because the name doesn't match.
880c8b3 to
e23967f
Compare
|
Note this also fixed the unreported issue on Linux/macOS that passing null or empty string to GetProcessesByName shouldn't filter anything out but was filtering everything out. |
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Linux.cs
Show resolved
Hide resolved
|
Improvement: dotnet/perf-autofiling-issues#5077 |
GetProcessesByName is loading all of the information for every process found, even if it'll immediately be thrown away because the name doesn't match.