Memory increase when travelling back and forth level
by Salamander · in Torque Game Builder · 08/14/2010 (2:28 am) · 6 replies
Hi everyone,
Recently i realized that when looking at task manager, memory used by my game increase slightly each time I'm traveling back and forth between 2 levels (working on an action/adventure game). I was wondering if there is anything i need to do that isn't done automatically by the engine so the memory is managed in the right way.
Maybe this is normal ?? If i stay in the same level, everything remains pretty stable.
I'm currently using tbg 1.7.4 + psk 1.1.1 (without source) since the beginning of my project. Everything works really well so far.
I'm very close from completing my game (hope to release it this year) so if anyone could help me
or at least point me to a thread i would be very grateful. I just don't know where to start...
Thanks a lot !
Recently i realized that when looking at task manager, memory used by my game increase slightly each time I'm traveling back and forth between 2 levels (working on an action/adventure game). I was wondering if there is anything i need to do that isn't done automatically by the engine so the memory is managed in the right way.
Maybe this is normal ?? If i stay in the same level, everything remains pretty stable.
I'm currently using tbg 1.7.4 + psk 1.1.1 (without source) since the beginning of my project. Everything works really well so far.
I'm very close from completing my game (hope to release it this year) so if anyone could help me
or at least point me to a thread i would be very grateful. I just don't know where to start...
Thanks a lot !
About the author
#2
Thanks !
08/17/2010 (10:24 pm)
Can someone give me a cue on this or should post my question on a different forum ?Thanks !
#3
There were memory leaks in 1.7.4. I'm specifically remembering the audio, but I think there were others.
Some memory increase is normal. When Torque requests more memory, it gets a block, but never frees it. I would switch back and forth between levels many times and record how much your memory goes up and report it here.
If it slows down and/or stops after a while, that's okay. If it continues to grow non-stop, but is only growing by a few bytes, I wouldn't worry too much about it. If it's growing by a megabyte each time and isn't stopping, that's a different problem.
Others might have suggestions, but upgrading to 1.7.5 would be best. I don't know if the PSK has been upgraded to that, so that's where your real problem might be.
08/18/2010 (4:23 pm)
There's no point in cleaning up the datablocks unless you have totally distinct sets for each level.There were memory leaks in 1.7.4. I'm specifically remembering the audio, but I think there were others.
Some memory increase is normal. When Torque requests more memory, it gets a block, but never frees it. I would switch back and forth between levels many times and record how much your memory goes up and report it here.
If it slows down and/or stops after a while, that's okay. If it continues to grow non-stop, but is only growing by a few bytes, I wouldn't worry too much about it. If it's growing by a megabyte each time and isn't stopping, that's a different problem.
Others might have suggestions, but upgrading to 1.7.5 would be best. I don't know if the PSK has been upgraded to that, so that's where your real problem might be.
#4
In the meanwhile i will investigate if i can use 1.7.5 with my current version of the PSK. I guess that Phillip should be the best person to speak to regarding this specifically ?
Whenever you have some free time, would you mind giving me an example on the simplest way to unload only some specific datablocks ? I may have to do this for my music once i switch to ogg for audio. Maybe there is a specific thread on how to do this, i didn't find a clear cut answer so far.
08/19/2010 (12:39 am)
Thanks a lot for your help William :) I'll try to provide more details on how much the memory increase as you suggested. In the meanwhile i will investigate if i can use 1.7.5 with my current version of the PSK. I guess that Phillip should be the best person to speak to regarding this specifically ?
Whenever you have some free time, would you mind giving me an example on the simplest way to unload only some specific datablocks ? I may have to do this for my music once i switch to ogg for audio. Maybe there is a specific thread on how to do this, i didn't find a clear cut answer so far.
#5
It's fairly easy to delete audio (at least in the fixed 1.7.5). You just have to call "YOUR_AUDIO_DATABLOCK.delete();".
For the image datablocks you have to have allowUnload set to "1" and then it's just the same: "YOUR_IMAGEMAP_DATABLOCK.delete();".
I go so far in my game as to manually create the t2dImageMapDatablocks, store them in an array, and delete them after the level is done. But my levels are also dynamically generated, so I don't need them in the TGB level editor.
08/19/2010 (1:14 am)
I thought of one other thing to check. Are you newing up anything? Like during an onLevelLoaded? Make sure that you are deleting any temporary SimSets or ScriptObjects that you create.It's fairly easy to delete audio (at least in the fixed 1.7.5). You just have to call "YOUR_AUDIO_DATABLOCK.delete();".
For the image datablocks you have to have allowUnload set to "1" and then it's just the same: "YOUR_IMAGEMAP_DATABLOCK.delete();".
I go so far in my game as to manually create the t2dImageMapDatablocks, store them in an array, and delete them after the level is done. But my levels are also dynamically generated, so I don't need them in the TGB level editor.
#6
08/23/2010 (1:29 am)
Nothing new apart from the data from the loading splash and the one used for the in-game hud. We cannot put theses in datablock can we ?
Torque Owner Salamander
Searching through the forums i didn't find a clear example.
Sorry if this is obvious stuff but this part is really confusing for me.
I don't mind if all my assets are loaded into memory all time as long as they aren't loaded again when loading a new level.
Maybe memory increase is normal ? Let me know if this doesn't make sense, i'm really confused, is everything managed automatically already ? Not sure if i should post this on the psk forum so any help would be really appreciated !
Thanks !