core icon indicating copy to clipboard operation
core copied to clipboard

【Terrible memory leak】 in dotnet core v3.1/3.0 Process.Start execute shell command

Open irac-ding opened this issue 6 years ago • 2 comments

Please Pay Attention !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! System: CentOS 7.2 SDK: 3.1.201

ex: class Program { static void Main(string[] args) { Console.WriteLine("Press any key to continue"); Console.ReadLine(); while (1 == 1) { List stdout = RunTaskAndReturnStdout("dotnet", $"--version"); } } }

public static List RunTaskAndReturnStdout(string fileName, string arguments, string workingDirectory = "") { List ret = new List(); try { using (Process proc = new Process()) { proc.StartInfo.FileName = fileName; proc.StartInfo.Arguments = arguments; proc.StartInfo.UseShellExecute = false; if (!string.IsNullOrWhiteSpace(workingDirectory)) proc.StartInfo.WorkingDirectory = workingDirectory; proc.StartInfo.RedirectStandardOutput = true; proc.Start(); while (!proc.StandardOutput.EndOfStream) { string line = proc.StandardOutput.ReadLine(); // Console.WriteLine(logstr); if (!string.IsNullOrWhiteSpace(line)) ret.Add(line); } return ret; } } catch (Exception ex) { return ret; } }

irac-ding avatar May 06 '20 06:05 irac-ding

https://github.com/dotnet/core/issues/3989 has found the issue which over passed over half year? There is no response which is almost unacceptable !!! Can any body investigate the problem ????

irac-ding avatar May 06 '20 06:05 irac-ding

Please keep discussion in the original issue.

GrabYourPitchforks avatar May 06 '20 07:05 GrabYourPitchforks