Very strange Memory Problem
by Chris Labombard · in Torque Game Builder · 09/21/2006 (10:12 am) · 17 replies
So Ive got my game almost complete and am trying to decrease my memory usage.
It was running at 183 MB of ram, which is insane.
I changed all my image datablocks and audio files to not preload and be allowed to unload. So now it runs around 150 MB. Still insane.
I tried commenting out all my scripts and execing the scripts 1 by 1... not allowing the game to load like normal.
I let all my scripts exec, except the gui files and it uses 43 MB. that includes all the audio and datablocks being exec'd.
If I exec the guis as well it takes up 112 MB. That makes no sense to me. ?
Anyways.... the very strange part is this :
If I exec all the scripts but dont run the game it loads to 112 MB. If I then minimize the window and then re maximize it it runs at 5 MB... If I then continue to run the game like normal it peeks at 75 MB, usually running around 50MB. If I minimize it in the middle of a game it runs at 6 Mb and slowly increases (very slowly) to around 30 MB....
I don't even know what to make of that. It seems like when the window minimizes it unloads all the crap that isnt needed and then it slowly loads it all as it becomes needed. Maybe the memory issues that people have had since 1.0.2 are caused by TGB not unloading things from memory when it no longer needs them ???
It was running at 183 MB of ram, which is insane.
I changed all my image datablocks and audio files to not preload and be allowed to unload. So now it runs around 150 MB. Still insane.
I tried commenting out all my scripts and execing the scripts 1 by 1... not allowing the game to load like normal.
I let all my scripts exec, except the gui files and it uses 43 MB. that includes all the audio and datablocks being exec'd.
If I exec the guis as well it takes up 112 MB. That makes no sense to me. ?
Anyways.... the very strange part is this :
If I exec all the scripts but dont run the game it loads to 112 MB. If I then minimize the window and then re maximize it it runs at 5 MB... If I then continue to run the game like normal it peeks at 75 MB, usually running around 50MB. If I minimize it in the middle of a game it runs at 6 Mb and slowly increases (very slowly) to around 30 MB....
I don't even know what to make of that. It seems like when the window minimizes it unloads all the crap that isnt needed and then it slowly loads it all as it becomes needed. Maybe the memory issues that people have had since 1.0.2 are caused by TGB not unloading things from memory when it no longer needs them ???
About the author
I have been a professional game programmer for over 5 years now. I've worked on virtually every platform, dozens of games and released a few of my own games, including 2 iPhone titles and a title waiting release on Big Fish Games.
#2
09/22/2006 (4:06 pm)
I'm pretty sure it's been stated by the GG folks that TGB will use as much memory as is available, though I dont know any specifics. I would like to point out, however, that there are 3 or 4 published titles in the 'casual' market using TGB, so I wouldn't go so far as to say that it isn't commercially viable.. :P
#3
I'd check this .blog post out, it may help shed some light.
09/22/2006 (4:54 pm)
Http://www.garagegames.com/blogs/4517/11311I'd check this .blog post out, it may help shed some light.
#4
09/22/2006 (7:56 pm)
Thanks Corey, that shed some light on the misconception.
#5
Some things are easy to analyze, and some things aren't!
But to back up Corey's posts--there are actually at least 6 currently published TGB titles (one from more than a year ago, back at early T2D stages), and many more rounding the bend into production--some from pretty big names.
09/23/2006 (1:29 am)
@Gelly: I'm still trying to figure out exactly what your mini-demo is really doing myself--and I know that it will be looked at.Some things are easy to analyze, and some things aren't!
But to back up Corey's posts--there are actually at least 6 currently published TGB titles (one from more than a year ago, back at early T2D stages), and many more rounding the bend into production--some from pretty big names.
#6
I'm not concerned with TGB having memory leaks.
I just want to know what is happening to cause the memory usage to drop so low when I minimize. If I can duplicate that in some way during run time then my game will go from running at 150 MB to running at 25 MB.
EDIT: If you want to discuss memory leaks and TGB's viability in the casual game space please use one of the threads that was actually started for that purpose.
09/23/2006 (6:44 am)
Uh... Maybe you guys didn't read my post... I'm not concerned with TGB having memory leaks.
I just want to know what is happening to cause the memory usage to drop so low when I minimize. If I can duplicate that in some way during run time then my game will go from running at 150 MB to running at 25 MB.
EDIT: If you want to discuss memory leaks and TGB's viability in the casual game space please use one of the threads that was actually started for that purpose.
#8
What about if I want to discuss how much of a prude you are? Is this a good place?
09/23/2006 (1:04 pm)
I'm not sorry. You were discussing memory issues and I sympathised with a similar situation as your having and added that I've encountered streaming issues with the memory as well.What about if I want to discuss how much of a prude you are? Is this a good place?
#9
What about if I want to discuss how much of a prude you are? Is this a good place?
09/23/2006 (1:05 pm)
I'm not sorry. You were discussing memory issues and I sympathised with a similar situation as your having and added that I've encountered streaming issues with the memory as well.What about if I want to discuss how much of a prude you are? Is this a good place?
#10
Please take off topic discussions to the threads that were started on those topics. If you'd like to discuss my prudeness please email me. This thread doesnt seem teh appropriate place to me. chrislabombard [at] hotmail [dot] com
EDIT: The reason you double posted is because you refreshed without first navigating off the thread and then back to it.
09/23/2006 (1:07 pm)
I really don't want to get into an argument. I just want to discuss what I found and find out where it's coming from.Please take off topic discussions to the threads that were started on those topics. If you'd like to discuss my prudeness please email me. This thread doesnt seem teh appropriate place to me. chrislabombard [at] hotmail [dot] com
EDIT: The reason you double posted is because you refreshed without first navigating off the thread and then back to it.
#11
Here I reported that the game was using an unbelievable amount of memory when it shouldnt be, sometimes it runs at 6k, sometimes 238mb:
http://www.garagegames.com/mg/forums/result.thread.php?qt=50895
Here is a recent blog from Robert Blanchet Jr. about memory, maybe this will help:
http://www.garagegames.com/blogs/4517/11311
09/23/2006 (1:20 pm)
What I was stating originally but I didn't elaborate was that I have had the same issue you are having and haven't couldn't get a response as to why.Here I reported that the game was using an unbelievable amount of memory when it shouldnt be, sometimes it runs at 6k, sometimes 238mb:
http://www.garagegames.com/mg/forums/result.thread.php?qt=50895
Here is a recent blog from Robert Blanchet Jr. about memory, maybe this will help:
http://www.garagegames.com/blogs/4517/11311
#12
I'm doing the same as you are... Instead of bitching or questioning Garagegames I'm working through torque with a debugger and trying to rally some help to find a solution for myself and everyone else.
I think I've found a solution to the problem. Even if it is indirect.
When you minimize your running game the memory usage drops from 150+ MB to 6 MB ... it then continues to run aroun 25MB ... Which seems exactly what it should be running at.
I'd rather not force a minimize but if we can find what happens when the app becomes minimized we may be able to keep the memory usage low in a similair way.
09/23/2006 (1:28 pm)
Yes, Ive read the blog and I've read the threads on memory leaks etc etc. I've also read several threads from people with games running upwards of 600 MB. I'm doing the same as you are... Instead of bitching or questioning Garagegames I'm working through torque with a debugger and trying to rally some help to find a solution for myself and everyone else.
I think I've found a solution to the problem. Even if it is indirect.
When you minimize your running game the memory usage drops from 150+ MB to 6 MB ... it then continues to run aroun 25MB ... Which seems exactly what it should be running at.
I'd rather not force a minimize but if we can find what happens when the app becomes minimized we may be able to keep the memory usage low in a similair way.
#13
The only thing I can think of is that when the TGB session first opens, Windows let's it do basically anything you want, but once you minimize it, it's relagated to "just another app", and most everything is forced to virtual memory. This has an implication of slowing down your session of course, but unless you're stressing it highly, you probably won't see it.
@All:
Guys (and gals, if appropriate), let's keep things at least civil, if not friendly! The idea of a community is mutual support and assistance, not conflict and dissent!
Sometimes it's best to just say (to yourself), 'ok, whatever!' and move on, instead of escalating what's most likely a misunderstanding in the first place.
09/23/2006 (2:33 pm)
@Chris:The only thing I can think of is that when the TGB session first opens, Windows let's it do basically anything you want, but once you minimize it, it's relagated to "just another app", and most everything is forced to virtual memory. This has an implication of slowing down your session of course, but unless you're stressing it highly, you probably won't see it.
@All:
Guys (and gals, if appropriate), let's keep things at least civil, if not friendly! The idea of a community is mutual support and assistance, not conflict and dissent!
Sometimes it's best to just say (to yourself), 'ok, whatever!' and move on, instead of escalating what's most likely a misunderstanding in the first place.
#14
Do you know of any way to look at how memory is used inside the app? Ive been googling around but I havent found anything useful.
Is there a way to force Torque to let go of the memory for images, sound, etc ?
09/25/2006 (11:15 am)
Stephen . That seems a bit vague. It makes sense I suppose. When you say everything is forced to virtual memory, where is it being forced from? Can you think of a way to maybe force it to do that automatically? I probably won't mind the slow down. Do you know of any way to look at how memory is used inside the app? Ive been googling around but I havent found anything useful.
Is there a way to force Torque to let go of the memory for images, sound, etc ?
#15
09/25/2006 (3:50 pm)
@Chris: you can mark them as canUnload I think the field is, and then kick them out of memory yourself. You don't however have any script level (or even c++ level) direct control over swapping to virtual memory--that's an OS operation.
#16
Perhaps I can call minimize, maximize on startup. I'll try that out and see what happens. maybe it wont look too funny.
09/25/2006 (7:58 pm)
I marked everything as "AllowUnload" but I dont know how to kick them out of memory. Is there a command for that ?Perhaps I can call minimize, maximize on startup. I'll try that out and see what happens. maybe it wont look too funny.
#17
09/25/2006 (9:53 pm)
Try looking in the image management pdf in your docs directory--it may have a sidebar discussion on loading and unloading images that could apply, or at least lead in the right direction.
Torque Owner Gellyware
Try streaming your audio and youll find that the memory increases forever until you minimize the window. The memory required nearly doubled in four hours in one experiment I had done.
I'd really like to know more about why this happens and how TGB will work on lower end machines (say 64 or 128mb memory). Unfortunately I dont have a machine like that to test it on... but I'm concerned that TGB might not be suitable to make casual games which is my major focus, I'd really not like to go back to using blitzmax because I really like TGB now... but it if isn't viable to use for commercial development then....