Important: Avoiding Memory Leaks
Posted: Thu Feb 05, 2009 4:12 pm
Having made many different styles of games with ge, i have learned a lot about the inner workings of the program. I found one of my game titles was experiencing terrible slowdown, but it seemed to be based on time and not on the number of actors or their activities.
I realize now that ge can spring bad memory leaks, a situation where every second it allocates another 12k of memory, and does so eternally until your cpu is at 99%. Use windows task manager and monitor ge's memory usage while playing to see if your game(s) have a leak.
While i have been unable to stop the leak, i have found ways to AVOID letting the leak ruin your game. (remember that post about crashes and errors i made?).
The 'collision map' that ge creates for actors has a problem when lots of clones check for lots of collisions. While massive bullets coming from your ship don't cause the memory leak, an enemy checking for collisions over and over can.
I had an enemy looking for the 'turn' markers to turn on the path; and the more turns it touched, the more the game leaked.
I have now replaced the collision with a draw actor, simply asking if the enemy is within 3 pixels of the turn actor, and i can now play through the game fully with no screen tearing or slowdown at all
IF YOU DON'T READ THE ABOVE, MAKE SURE TO READ THIS:
If you do not need a collision, do NOT have one! Disable collisions for ANY actor that won't be using them!
In this case, draw actor checks, even distance(!), are much more stable than using collisions, not to mention(and its documented in the source) that collision checks eat a lot of cpu anyway!
Also, try not to use 'collision>anyside>ANY ACTOR', it is quite likely to ruin your game. Just stop and think about what you're asking the program to do there; Its wasteful, illogical, and certainly not the way a professional would handle collisions in his game. You might not care about the player's cpu, but, i assure you, your player does! If player could afford a faster computer, player would buy a faster computer! You have to treat user's cpu cycles like gold!
Note: (realize i'm not slamming ge)
If you have been experiencing problems with collisions, or with physical response, and they give you doubts about GE, i invite you to check the collisions in other popular game maker software, even some 'pro' kits, and you'll see that its not easy to make good collisions.
My game 'Orbs of Death' (viewtopic.php?f=6&t=5513) could NEVER have been made with GM , because its collision engine(while seemingly leakproof) is unrealistic, unpredicable, and terribly jerky in terms of gameplay.
I realize now that ge can spring bad memory leaks, a situation where every second it allocates another 12k of memory, and does so eternally until your cpu is at 99%. Use windows task manager and monitor ge's memory usage while playing to see if your game(s) have a leak.
While i have been unable to stop the leak, i have found ways to AVOID letting the leak ruin your game. (remember that post about crashes and errors i made?).
The 'collision map' that ge creates for actors has a problem when lots of clones check for lots of collisions. While massive bullets coming from your ship don't cause the memory leak, an enemy checking for collisions over and over can.
I had an enemy looking for the 'turn' markers to turn on the path; and the more turns it touched, the more the game leaked.
I have now replaced the collision with a draw actor, simply asking if the enemy is within 3 pixels of the turn actor, and i can now play through the game fully with no screen tearing or slowdown at all
IF YOU DON'T READ THE ABOVE, MAKE SURE TO READ THIS:
If you do not need a collision, do NOT have one! Disable collisions for ANY actor that won't be using them!
In this case, draw actor checks, even distance(!), are much more stable than using collisions, not to mention(and its documented in the source) that collision checks eat a lot of cpu anyway!
Also, try not to use 'collision>anyside>ANY ACTOR', it is quite likely to ruin your game. Just stop and think about what you're asking the program to do there; Its wasteful, illogical, and certainly not the way a professional would handle collisions in his game. You might not care about the player's cpu, but, i assure you, your player does! If player could afford a faster computer, player would buy a faster computer! You have to treat user's cpu cycles like gold!
Note: (realize i'm not slamming ge)
If you have been experiencing problems with collisions, or with physical response, and they give you doubts about GE, i invite you to check the collisions in other popular game maker software, even some 'pro' kits, and you'll see that its not easy to make good collisions.
My game 'Orbs of Death' (viewtopic.php?f=6&t=5513) could NEVER have been made with GM , because its collision engine(while seemingly leakproof) is unrealistic, unpredicable, and terribly jerky in terms of gameplay.