4

有时我会收到错误

Win32Exception 没有足够的存储空间来处理这个命令

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

这对应于系统错误

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 上运行。

4

2 回答 2

3
于 2015-06-10T12:15:27.483 回答
0

调用RegisterClass导致内存错误。请参阅为什么 RegisterClass 因 ERROR_NOT_ENOUGH_MEMORY 而失败?. 您的应用程序调用RegisterClassRegisterWindowsMessage多次?

于 2015-03-11T00:11:36.977 回答