views:

460

answers:

4

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

A: 

There's two things I can suggest here:

1) Maybe your machine is running out of memory. Check out some ideas on http://digioz.blogspot.com/2008/11/visual-studio-systemoutofmemory.html

2) Try compiling the project outside of visual studio using the VS Command line utility and run msbuild "SolutionfileName.sln". Does your it still crash then?

Hope that helps :)

FailBoy
A: 

I hope you mean runtime error, and not compile-time error.

Typically this would happen if you have a list growing, which is saved in a static field or a system-wide ASP.NET container.

You can run the application in a profiler, like:

Red gate ants profiler

taoufik
A: 

Sorry above, but to me it has happened more than 3 times - Redgate broke either VS or the whole Windows ... Try this approach. I quess the root cause for your problem is weak debugging , check log4net. Also simple if ( DebuggingFlag == true ) Response.Write ( "DebugMsg" )

might be useful as simple and absurd it sounds ...

YordanGeorgiev
A: 

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.

Johannes Rudolph