runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Process.Start() creates additional process named conhost.exe

Open dooann opened this issue 2 years ago • 3 comments

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:

  1. Is conhost.exe necessary for starting a process? If so, why?
  2. Can we remove conhost.exe or 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

dooann avatar Nov 24 '24 13:11 dooann

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

dooann avatar Nov 24 '24 14:11 dooann

Closing as answered

stephentoub avatar Nov 24 '24 22:11 stephentoub