简体   繁体   中英

How can I debug an OutOfMemoryException in ASP.NET?

I am reading an .opml file and parsing it to generate a list of articles for each rss feed I subscribe to and thus add into this .opml file.

At times, when pressing play on Visual Studio (Run), I get an error (not exception) stating an OutOfMemoryException. This is before the application can even run (but has compiled). The page in question (the error comes in the output window with the relevant page) is the RSS Reader page, which calls the methods to do the parsing.

How can I completely fix this error? This error only comes up at times so it is hard to reproduce. Some information points to an issue with my dev environment, not the site or Visual Studio (This could mean another set of variables when live). Has this exception got any link to a potential memory leak (is it a possible warning)? Would memory profiling help (I have a memory profiler)?

Thanks

If I understand correctly, Visual Studio itself is OOM and reporting that it cannot start the debugg process. Is the devenv.exe process using a lot of memory? If you are under VS 2005 on a 64 bit OS you can try the advice from this post to make the devenv.exe use 4GB and perhaps aleviate your problem.

If is not VS itself that is OOM, you'll need to locate the problem. The culprit should be the one that shows up in task list with a large VM size. Running VS itself under debugger may help. Also, sometime system errors (like kernel resource exhaustion) are translated to OOM error.

How are you parsing this? You can run out of memory in a variety of ways, such as doing this in a tight loop:

for(....)
{
  //Creates immutable strings faster than they can be garbage collected 
  nextXMLPart = nextXMLPart + " " + something;
}

How big is the file? If you are reading the entire file into memory that would do it.

Any how, I'd start looking at any loops that repeat a lot. And if that doesn't work, fire up task man and put break points in the code. Watch for where the app is when memory usage starts to shoot up.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM