gpt4 book ai didi

c# - 作为 Windows 服务运行时出现 "Win32Exception Not enough storage is available to process this command"错误

转载 作者:行者123 更新时间:2023-11-30 16:08:38 24 4
gpt4 key购买 nike

有时候会报错

Win32Exception Not enough storage is available to process this command

在应用程序运行大约一个月左右之后。

这对应于 system error

ERROR_NOT_ENOUGH_MEMORY (8)

通常,它作为 Windows 服务运行,更改登录用户仍然会导致错误发生。但是,如果我通过双击运行该应用程序,它可以正常工作。它可以再次作为 Windows 服务运行的唯一方法是重新启动服务器。

错误出现在应用程序写入的日志中。完整的错误是:

System.ComponentModel.Win32Exception: Not enough storage is available to process this command
at System.Windows.Forms.NativeWindow.WindowClass.RegisterClass()
at System.Windows.Forms.NativeWindow.WindowClass.Create(String className, Int32 classStyle)
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Application.MarshalingControl..ctor()
at System.Windows.Forms.Application.ThreadContext.get_MarshalingControl()
at System.Windows.Forms.WindowsFormsSynchronizationContext..ctor()
at System.Windows.Forms.WindowsFormsSynchronizationContext.InstallIfNeeded()
at System.Windows.Forms.Control..ctor(Boolean autoInstallSyncContext)
at System.Windows.Forms.ScrollableControl..ctor()
at System.Windows.Forms.ContainerControl..ctor()
at System.Windows.Forms.Form..ctor()
at LicensingModule.LicenseKeyValidator..ctor(String Name, String Path)
at MIDICOMExporter.Program.Main(String[] args)

我看到其他的回答说是服务器内存泄漏有关,但是如果应用程序在双击时仍然可以运行,是否仍然意味着可能存在内存泄漏?

此外,它在 Windows Server 2012 上运行。

最佳答案

是的,问题可能与服务器上的内存泄漏有关。也许是 desktop heap耗尽。 “非交互式”窗口 session 的桌面堆不同于真实(交互式)桌面 session 的桌面堆。这解释了为什么仍然可以双击该应用程序。

尝试查找注册表项\System\CurrentControlSet\Control\Session Manager\SubSystem 并增加 SharedSection=xxx,yyy,zzz 的第三个参数 (zzz),如 MSKB 126962 中所述(对于 yyy)。

The third SharedSection value (512) is the size of the desktop heap for each desktop that is associated with a "non-interactive" window station.

如果这解决了您的问题,例如由泄漏资源引起的堆耗尽可能是您问题的根源。默认情况下,“非交互式”桌面堆的大小远小于标准堆。

关于c# - 作为 Windows 服务运行时出现 "Win32Exception Not enough storage is available to process this command"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28920550/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com