infinite loops crashing my computer

liptonIcedTea

Well-known member
Joined
Jan 18, 2007
Messages
89
Programming Experience
1-3
Hi,

I've got an asp.net application where I've got alot of while loops. Occassionally, I'll accidentally forget to increment the i or whatever, and throw an infinite loop.

The problem is it actually crashes my computer! I've tried IISRESET, killing visual studio, but i dunno, it just slows my computer down to the point it's unworkable.

My theory is that IIS puts my app in a seperate process. This process is not killed by IISreset until it gets out of a method, but because of the infinite loop, it never comes out of this method and therefore is never killed.

Is there any way around this? I'm clumsy enough to not never throw an infinite loop again and I don't want to have to reset my computer every time i do one.
 
I've had this happened to me on a number of occasions. I found that Task Manager is pretty good at doing this. If you run VS in debug mode the it's better to use control-break sequence than killing VS itself. Otherwise launch TM and kill the process.

I find that it works out better if I compile the code and run the page in IE rather than doing debug mode all the time. I only go into debug mode when there's a real issue.

Also, to prevent this from happening, I make it a habbit to make sure that the first thing I do when setting up a loop is to increment the counter or what not to prevent looping. And when testing, set a counter to limit the number of loops... once everything works out, remove the uneccessary conditions.
 
Back
Top