I get this exception in my application. I have found links discussing it on the web but nothing indicating how to track it down and/or workaround it.
Please do not reply
In my case it turned out the application in question was already pressing up on memory limits of its specced hardware. Any time I added code that used a decent amount of memory this would crop up.
I ended up using a MemoryFailPoint
mechanism when I implemented a feature that placed processing an image buffer on another thread.
https://docs.microsoft.com/en-us/dotnet/api/system.runtime.memoryfailpoint
First implementation did the trick but after many tries QA caused a OOM bomb.
So I implemented a MemoryFailPoint()
with GC.Collect()
loop (hackish I know...but sometimes...get er done).
The main things I learned were: