dotnet/winforms

Stop throwing OutOfMemoryException for GDI+ errors in System.Drawing

Opened this issue · 0 comments

GDI+ returns Status.OutOfMemory for many general purpose errors. This is deeply confusing for users and almost never happens due to an actual lack of memory.

I'm inclined to change this behavior to always throw InvalidOperationException with a message along the lines of:

GDI+ returned Status.OutOfMemory. This is usually a general error and not a lack of memory.

I can't know for sure that there isn't a low memory situation, but if it is other things are likely to fail imminently for lack of memory anyway.

I'd offer an AppContext opt-out switch that would throw with the old behavior.