|
Game Freezes at Random |
Onewing
Member #6,152
August 2005
|
I had an epiphany as I wrote the title to this post. See, several of my allegro programs tend to freeze at will randomly when developing. As far as I know, there's not any problems with the binary freezing. And when I say random, I mean it. It could be five seconds, five minutes or thirty minutes before it freezes. When I Ctrl-alt-delete, the program says "Program Not Responding" under status. I figured it had something to do with maybe my timer logic, since the problem seems to span several of my latest works. However, if it did get locked up due to bad timer logic, wouldn't task manager say "Running" {implicitly meaning indefinitely}? Anywho, the epiphany came when I asked myself how long this has been occurring. I don't remember ever having this problem with cosmos, but if I remember correctly (after checking, I do), I hadn't upgraded to allegro 4.2 by that point. So it would seem the problem didn't start till I upgraded to allegro 4.2, but who knows, that might just be a coincidence. As for timer logic, it's rather simple:
//game.h ... extern volatile int draw_ticks; extern volatile int ticks; extern volatile int framerate; extern volatile int system_time; void timer1(void); void timer2(void); ... Lastly, the main loop, also in game.cpp
As for further timer logic, I give most classes an int "update_timer" and do the following: ... if(abs(ticks - update_timer) > update_delay) { update_timer = ticks; //Do stuff ... }
------------ |
ImLeftFooted
Member #3,935
October 2003
|
Random freezing is my greatest fear. I avoid it at all costs. The best trick I've found is running it in a debugger and breaking as soon as the pause occurs. Then ofcourse evaluating the stack tree. Sometimes it takes a couple tries to land it just right and sometimes you'll even find the program will hang in a couple of places. The absolute worst kind is when it hangs randomly every 30 min+ and only lasts a few seconds. That kind of bug will make you want to shoot yourself. [edit] [edit] |
piccolo
Member #3,163
January 2003
|
the problem is most likely a memory leak if your in winxp open the task manager go to the processes tab and watch the mem usage of your game exe. wow |
ImLeftFooted
Member #3,935
October 2003
|
I was wrong again. I was looking at the frame timer and thought it was the logic timer. Do the debugger trick. |
Matthew Leverton
Supreme Loser
January 1999
|
Which OS are you using? |
Onewing
Member #6,152
August 2005
|
Quote: Which OS are you using? WindowsXP and should be in synch with Windows Updates. ------------ |
Kris Asick
Member #1,424
July 2001
|
Try giving some time back to the OS every game loop using rest(0) or Sleep(0). I've found that on Windows 98 using Allegro 4.1.0 or higher, I have to use rest(1) or Sleep(1) to prevent the keyboard, mouse and joystick I/O from locking up for split seconds every so often. (Thus for each frame I end up giving 1 ms of time back to the OS.) --- Kris Asick (Gemini) --- Kris Asick (Gemini) |
Onewing
Member #6,152
August 2005
|
I can try it, but I don't think it's right. My programs are freezing and staying frozen until I kill them. ------------ |
Richard Phipps
Member #1,632
November 2001
|
Does it work with other games? |
Onewing
Member #6,152
August 2005
|
Any more ideas in the mean time? It's hard to determine if there is a problem with running the allegro demos, but I'll run them for a while and see if anything happens later on when I have that kind of time. ------------ |
GullRaDriel
Member #3,861
September 2003
|
Onewing: can we have the whole code ? I really wanna help, and having the whole source can allow us some debugging. "Code is like shit - it only smells if it is not yours" |
Audric
Member #907
January 2001
|
Quote: install_int_ex(frametimer, BPS_TO_TIMER(1)); This is a 1000 Hz timer. Bad stuff is supposed to happen if you use these...? |
Indeterminatus
Member #737
November 2000
|
Quote: This is a 1000 Hz timer. No, that's a 1 Hz timer. Nothing wrong with that. _______________________________ |
Onewing
Member #6,152
August 2005
|
Quote: Onewing: can we have the whole code ? Well, I had the problem with Toggles, a game I released back in August '06. I believe I packaged the source with that, but it's pretty big. For the new game, the source code is, just guessing, 5000+ lines of code. Since the problem spans several programs, I'd either expect it to be non-code related or something to do with my timer logic. ------------ |
|