GurdeepS
GurdeepS

Reputation: 67223

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

Upvotes: 6

Views: 9766

Answers (4)

Johannes Rudolph
Johannes Rudolph

Reputation: 35741

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.

Upvotes: 5

Yordan Georgiev
Yordan Georgiev

Reputation: 5430

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 ...

Upvotes: 1

tofi9
tofi9

Reputation: 5853

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

Upvotes: 1

StevenMcD
StevenMcD

Reputation: 17482

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 :)

Upvotes: 1

Related Questions