Game slowing down over time?
Blitz3D Forums/Blitz3D Programming/Game slowing down over time?
| ||
Can anyone point me in the right direction for this? I have a game which loops through a number of routines fairly continuously. However, it seems to be taking a little more memory/system resource each time around as after about 10 minutes it starts to stutter and slow down. I am not declaring any new variables, loading any new images or leaving any loops open - can anyone help me out with this? Is there any way to clear unused memory during runtime? What am I missing? Tony D |
| ||
Creating any type instances? Creating any geometry? or textures? Using the debuglog? |
| ||
I am using the debuglog - I will remove all calls to that and see how it helps. Thanks! |
| ||
What sort of thing are your loops doing? |
| ||
You haven't got something like a=loadmesh("blah.b3d") or similar in your main loop have you? I did that once , was most confuzzling for a few minutes. |
| ||
I've found that when writing alot of info to the debuglog things slow to a canter after a while. |
| ||
As the debug log file gets bigger it will get slower ! Make sure you are not writing too many lines to the debug log - avoid writing to the debuglog from loops etc. |
| ||
I once had a bug in my game where I was allocating a pivot every frame accidentally. After 10-15 minutes the game speed would start dropping rapidly ... was most confusing until I systematically broke the game down and found the offending line. |
| ||
I had a similar problem EpicBoy... in my first 3D sound test I was making a pivot to mark the location of every sound played but not deleting them when the sounds finished. Took me forever to find the bug too. |
| ||
Instead of constantly writing to the debuglog, perhaps you could try storing the debug data in a Type and then save the resulting Type chain to a file when your program ends. |
| ||
The only things I can think of that would cause the game to slow down (it's a lot better without the debuglog calls - but it still slows after a while) are: - New graphics are being created within loops. These are being done by making copies of existing graphics which are held as global variables - Same thing with 3D objects. I have a game board with a number of pieces which change relative to the current game activity, so I have 30 placeholder objects which I loop through and change Would either of these activities cause the problem? |
| ||
I would suggest to double check if you 'create' something during your main loop. Pivots, meshes, textures, image buffers, timers, handles to read a directory, sprites, memorybanks, sounds, music, etc. All these things can be loaded/created and need to be 'freed' when you're done with them. I always keep track of the amount of objects with variables like NUM_SPRITES or NUM_SOUNDEFFECTS. Increase them if you add something, and substract 1 when you remove something. That way, when I delete everything, those NUM_xx variables should all be 0. That way I know nothing is 'leaking through'.... hope this helps, Danny |
| ||
might wanna make sure you're not running multiple instances of bb3d or bb3d windows as well, especially with debug enabled. |