Testing script that causes a crash

I have quite an expansive script that I’m currently testing, unfortunately when I try to run it Blender starts not responding, meaning no error report and no idea on my part as to where it’s gone wrong, is there a way I can easily find where the script is messing up. All I can think to do at the minute is shove if statements all over the place to run it bit by bit but I don’t fancy doing that, it would be very time consuming.
I suspect my problem lies inside one of my while statements so my second question is does blender have a memory ‘limit’ that could cause an error before the while statement has finished executing.
Thanks

I am not a BGE guru but in my experience you should not use loops. You should let the sensors and the controllers do the loop for you. Once i added a While and the performance went seriously down, i removed it and modified my script (and split it) and everything worked fine.

I don’t really know what i am talking about know but i think ifyou try to make a loop inside a controller that is supposed to get executed in an instant it will stop everything else OR if the app is threaded unexpected things will happen because something else is happening at the same time. Anyway python loops have never worked well for me in BGE i looped things using the sensors and python controllers with conditional statements. Hope that helps. And if you want to post the script for other people to check if works or what is wrong with it…

Periodically put print statements in. like:

print 0
...code...
print 1
...code....
print 2
...code...

And check the console for the last print out before blender freezes (maybe add a time delay so you can get the console open before it freezes), then keep narrowing it down until you find the problematic line.

Like K11 also said, be wary of loops.

Thanks for the help guys, I was right it was the while loop. I ended up putting a counter in the while loop with an if statement to quit so that blender didn’t crash and I could test it better.