I have an application that works with large amounts of data, and I’m thinking that, may be, sometimes the OutOfMemoryException will be thrown (For half a year, I got no single exception, but I’m just want to know all about it). As I’ve investigated, after this exception I can’t proceed with execution of my program.
Is there any good pattern to handle such exceptions, especially to working with IDisposable classes?
In a genuine OOM scenario (more likely on x86 than x64) you are pretty doomed there. Almost anything would cause an allocation, so your best option is to die as quickly and elegantly as possible, doing minimum harm.
Since it isn’t happening, don’t stress overly, but avoidance is better than handling here: