0

My clients sometimes encounter "Not enough quota" exception on their machines ( and I get to know about it only because they send in their log files), with this typical stack trace:

PresentationCore: System.ComponentModel.Win32Exception Not enough quota is available to process this command at System.Windows.Interop.HwndTarget.UpdateWindowSettings(Boolean enableRenderTarget, Nullable`1 channelSet) at System.Windows.Interop.HwndTarget.UpdateWindowPos(IntPtr lParam) at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam) at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)

Since it appears very randomly and rarely, I've given up hope to try to reproduce the issue and fix it from my application side.

The next best thing I can do is that I want to capture this exception, display a nice dialog box for the users, ask them to take remedial action ( such as this) and/or to restart the application/Windows.

I've been thinking about using WPF global exception handler, but I'm not sure at all if handling the Application.DispatcherUnhandledException Event can properly catch this exception. The reason is that Not enough quota happens often because Windows is running out of virtual memory to assign, and from what I can recall for this kind of out of memory issue, .NET exception handler doesn't work.

So how can I handle this situation?

Graviton
  • 81,782
  • 146
  • 424
  • 602
  • Handling all unhandled exceptions to exit gracefully is good idea. There are also unabservable task exceptions, which you may want to setup to crash the software too. And specifically to your case, try and see if that approach works. It could be there is no problem to do so. – Sinatr Apr 16 '21 at 10:33
  • Make sure your swap space is set so a drive will be used for memory if you exceed the memory on the machine (or add more memory to the machine). See : https://superuser.com/questions/793304/how-to-increase-swap-memory-in-windows/793325?force_isolation=true – jdweng Apr 16 '21 at 10:54

0 Answers0