Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Diagnose A System.OutOfMemoryException?

I ran some code last Friday before leaving work, and I'm here on Monday, and it stopped with an OutOfMemoryException. This entire process I estimate required making tens of billions of calculations, so it wasn't some small task.

I don't even know how to begin fixing this.
Any pointers?

like image 997
sooprise Avatar asked Sep 13 '10 12:09

sooprise


People also ask

What causes system OutOfMemoryException?

When data structures or data sets that reside in memory become so large that the common language runtime is unable to allocate enough contiguous memory for them, an OutOfMemoryException exception results.

What does exception of type system OutOfMemoryException was thrown mean?

OutOfMemoryException' was thrown. Cause: The reason this error is occurring is because the computer in use is running out of physical RAM memory and is unable to allocate the necessary RAM to complete the task.


1 Answers

If you are allocating very large arrays repeatedly, you may be running into Large Object Heap Fragmentation. If this is the case, you may need to consider whether you can reuse work arrays to prevent the re-allocations and subsequent fragmentation. I definitely recommend running a memory profiler, however, as it's more likely that you have something lingering in memory past what you assumed was its expiration date.

like image 193
Dan Bryant Avatar answered Sep 27 '22 19:09

Dan Bryant