Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to predict Out of memory?

In my C# program I do various memory-consuming operations. Depending on the amount of memory currently available and various non-constant circumstances, the program fails with OutOfMemoryException at different stages.

I would like to stop processing at some point when it is more or less obvious that the program will fail with an OOM in the near future.

However, there is no fixed threshold for this; Other users may have more (or less) memory, another OS with its memory specifics and so on.

I do not want to just check that the software consumes more than eg 500MB as this may be too high or too low a restriction.

Is there any reliable way to predict an upcoming OOM in .NET?

like image 747
Alex Avatar asked Sep 11 '12 09:09

Alex


1 Answers

MemoryFailPoint should do what you want.

http://msdn.microsoft.com/en-us/library/system.runtime.memoryfailpoint.aspx

like image 102
Gung Foo Avatar answered Sep 29 '22 19:09

Gung Foo