6

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

4
  • 2
    What exactly do you mean, it's a compile time error? Is the compiler throwing an OutOfMemoryException? Commented Apr 25, 2009 at 20:30
  • 2
    A compile time out of memory would indicate that you've got some REALLY weird source code. The only way that I can think of in C++ to do that would be recursive include files (i.e. a.h includes b.h while b.h includes a.h) - does C# have some similar concept? You've basically got to be doing something that's causing the parse tree to blow up. Commented Apr 25, 2009 at 20:40
  • Yes, the compiler itself is throwing the error. There is no ysod, but an error in the output window when attempting to debug. I think the culprit is I have a 3mb xml file which I parse (it has rss feeds) and then display in a custom rss feed reader. I closed the dev web server and got it sorted. Commented Apr 27, 2009 at 9:11
  • In my case, it was a crystal report ( RPT file) who was causing all the trouble, i exclude the file and the proyect started to work properly. Commented Jun 26, 2020 at 17:26

4 Answers 4

5

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

1

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

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.