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
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.
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.
Throw New OutOfMemoryException() Catch e As ArgumentException Console. WriteLine("ArgumentException in String. Insert") End Try ' Execute program logic. Catch e As OutOfMemoryException Console.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With