Process.Start() creates additional process named conhost.exe
I found that the Process.Start() creates additional process named conhost.exe for each call while the subprocess module in python is not.
Each instance of conhost.exe consumes approximately 5.7 MB of memory, which limits the level of concurrency.
It also affects the pwsh scripts. Actually, I found this issue when writing the pwsh script.
My questions are:
- Is
conhost.exenecessary for starting a process? If so, why? - Can we remove
conhost.exeor provide an option to control its behavior?
Thanks.
var info = new ProcessStartInfo("ping") {
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true,
Arguments = "google.com"
};
var process = Process.Start(info);
.Net version: 8.0.401
subprocess.run(['ping', 'google.com'])
Python version: Python 3.12.3
Tagging subscribers to this area: @dotnet/area-system-diagnostics-process See info in area-owners.md if you want to be subscribed.
OK. The solution is set CreateNoWindow = false.
Reference: https://stackoverflow.com/questions/53328013/launch-windows-executable-without-conhost
Closing as answered