Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging outofmemoryexception

In the bug fixing of a small ASP.NET/C# web app I have made, I have encountered an OutOfMemoryException.

There is no tips as to where to look as this is a compile time error. How can I diagnose this exception? I am assuming this is exactly where memory profiling comes into play? Any tips?

Thanks

like image 453
GurdeepS Avatar asked Apr 25 '09 20:04

GurdeepS


People also ask

How do you debug OutOfMemoryException?

To start debugging the OutOfMemoryException , I recommend you to look at your application either through the Task Manager or using perfmon. msc . Both tools can track the current memory consumption, but to get a better overview over time, perfmon is the best.

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.

How do you handle out of memory exception in VB net?

Throw New OutOfMemoryException() Catch e As ArgumentException Console. WriteLine("ArgumentException in String. Insert") End Try ' Execute program logic. Catch e As OutOfMemoryException Console.

How can avoid out of memory error in C#?

Well, according to the topic of the question, best way to avoid out of memory exception would be not to create objects that fill in that memory. Then you can calculate the length of your queue based on estimate of one object memory capacity. Another way would be to check for memory size in each worker thread.


1 Answers

You should take a memory dump of your program at the point in time OutOfMemoryException occurs and analyze what's taking up so much memory.

Tess Ferrandez has an excellent How-To series on her blog.

like image 173
Johannes Rudolph Avatar answered Sep 30 '22 13:09

Johannes Rudolph