运行 处理来自用 C# 编写的 windows 服务时的内存问题
Memory issue while running processes from windows service written in C#
运行ning 处理来自用 C# 编写的 windows 服务时的内存问题:
我正在尝试 运行 使用下一行的一些进程:
for (int i = 0; i < runParamaters.Count; i++)
{
ProcessStartInfo pe = new ProcessStartInfo(runParamaters[i].command, runParamaters[i].parameters);
pe.WorkingDirectory = runParamaters[i].folder;
System.Diagnostics.Process.Start(pe);
}
虽然运行从命令行 exe 或 winform exe 运行此循环,但它工作正常。但是 运行 从服务中调用它(在它的 "start" 函数上)- 一些进程无法分配内存并失败了。
知道为什么以及如何修复它吗?
不确定您尝试的是哪种程序运行,但我会试试这个:
pe.CreateNoWindow = false;
pe.UseShellExecute = false;
问题是 OS 为服务分配的堆内存较少。解决方案是编辑密钥 HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\SubSystems\Windows
使用 regedit 以设置更多堆。非常感谢spodger。
运行ning 处理来自用 C# 编写的 windows 服务时的内存问题: 我正在尝试 运行 使用下一行的一些进程:
for (int i = 0; i < runParamaters.Count; i++)
{
ProcessStartInfo pe = new ProcessStartInfo(runParamaters[i].command, runParamaters[i].parameters);
pe.WorkingDirectory = runParamaters[i].folder;
System.Diagnostics.Process.Start(pe);
}
虽然运行从命令行 exe 或 winform exe 运行此循环,但它工作正常。但是 运行 从服务中调用它(在它的 "start" 函数上)- 一些进程无法分配内存并失败了。
知道为什么以及如何修复它吗?
不确定您尝试的是哪种程序运行,但我会试试这个:
pe.CreateNoWindow = false;
pe.UseShellExecute = false;
问题是 OS 为服务分配的堆内存较少。解决方案是编辑密钥 HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\SubSystems\Windows 使用 regedit 以设置更多堆。非常感谢spodger。