Game Development Community

Excessive T2D memory usage?

by Christopher Gu · in Torque Game Builder · 09/08/2005 (5:53 pm) · 18 replies

Hey guys, I've been working on a project all summer, and the other day I made a bit of a troubling discovery....T2D uses up 152 megabyte when running my simple game! I couldnt believe my eyes, I thought I had done something dreadfully wrong in my code. I then proceded to check out the demos that came with my purchase of T2d. 188mb of RAM for the fish demo! Whats going on here? Is this a known issue? Will memory usage be lessened in the final release?

Also, just for referance, how is the memory usage in TGE?

#1
09/08/2005 (9:04 pm)
I'm getting 47 megs for the shooter demo and 75 for the fish demo....I was just playing the game Luxor, and it was 57...

I would assume that once you've created your game there may be some things you could do to minimize memory usage, like clearing out T2D code that isn't being used or something...
#2
09/08/2005 (9:06 pm)
Kinda OT, but.. Was Luxor made with T2D? I hadn't seen any posts about it- i'd figure someone would've been quick to point out another T2D project going commercial. :)
#3
09/08/2005 (9:15 pm)
The Fish demo uses 68 MB on my computer (Win XP). Christopher are you sure you are looking at the right T2D process?

Gold Fever, the 1st commercial game for T2D, uses like 156 MB of memory on my computer! That's surprisingly high.

The last time someone posted this question in the forums, it turned out they had like a 128 MB OGG or MP3 file that was being loaded into their T2D, which will obviously hurt memory usage. . :-)

So I guess you just have to be smart about how you load graphics and sounds, if you have a lot of resources in your game. I think more about that, than anything.
#4
09/08/2005 (9:22 pm)
Luxor isn't a T2D game...I just mentioned that since I was playing it at the time and it was similar to the T2D memory. I was just playing the Little Gods game (A T2D game) and it barely went above 10 megs! Interesting.
#5
09/08/2005 (9:40 pm)
The shmup i've been working on uses 27megs at peak. This increases to more like 35-40 when im playing one of the included .ogg's, though, which is still not a bad number.

One thing you should remember is to use a Release compiled t2d.exe. The Debug compile produces a larger .exe, and I would presume, uses more memory because of the debug hooks (though tbh, i don't know much about the real impact of debug versus release compiles beyond file size).
#6
09/08/2005 (9:43 pm)
Good point Corey - I was reading in another thread that DEBUG build on most compilers significantly changes how memory management is done in the running app.
#7
09/09/2005 (6:16 am)
.ogg and .mp3 files really shouldn't affect memory usage dramatically noticably no matter what their size. They're streaming formats, meaning that a few bytes are read at a time into a buffer, decompressed, played, and overwritten with the next chunk of the stream. Unless there's significant overhead in the vorbis codec runtime (not sure what this is like), playing an .ogg file should never really increase your memory useage noticably. The story of the 128 MB OGG file could possibly be someone reading and decompressing the entire thing in one big buffer, but the resulting data would probably be a helluva lot bigger than 128 MB.

I would definitely be interested in more specific data around T2D's memory usage with a bare bones app.
#8
09/09/2005 (6:18 am)
I had the .ogg set to preload at the time, so it probably decompressed and cashed the whole thing in memory.
#9
09/09/2005 (6:35 am)
The shooting demo uses 60Mb on my development machine and 400Mb in 1/4 cases.... The aquarium demo is using 600Mb in 1/5 cases too...
I hope the new version of T2D was corrected...
Or it's just a demos' code problem?
#10
09/09/2005 (6:38 am)
... because as has been mentioned numerous times, the demos we released were not to show how little memory you can use, how fast T2D is or how great the graphics you can get in there although we should/will do demos that do. Most of these demos were put together very quickly indeed. One of the reasons why the fish demo is excessive is that all the fish use chunked imageMapd and the overheadd related to that.

As Steve mentioned, Little Gods takes very little memory and most of your apps will simply because you'll spend more than 10-20 hours writing them!

In the future, any demos will have much more love given to them.

- Melv.
#11
09/09/2005 (7:26 am)
Quote:I would definitely be interested in more specific data around T2D's memory usage with a bare bones app.

Why not try it?

On my machine, T2D.exe with no datablocks, no sound, and $runWithEditors = false, etc. uses 18MB only. That's barebones. Not sure how LittleGods can only be using only 18MB, but we can see from this thread that resource usage differs on each machine.

It's strange that the Fish demo is at times using 600MB of memory on Alexander's machine. Something seems very wrong there. I have been running it for a few minutes and it's still at only 68MB.
#12
09/09/2005 (9:23 am)
I think the engine expands (ie, caches assets and holds them) as needed according to the limits of your machine's RAM. I'm guessing, but that's what my experiments lead me to believe. It makes sense, as it allows machines with more RAM to precache more stuff for less twitching during play.
#13
09/09/2005 (11:14 am)
... also, v1.0.2 was keeping the bitmap in memory well after it had been processed and upload to the GPU. This, of course, has now changed.

- Melv.
#14
09/10/2005 (2:33 pm)
Hey guys, thanks for all of the replies and great suggestions. I'll be sure to try all of them.

I have one more quick question though....which file contains the line where I can set $runWithEditors to false?
#15
09/10/2005 (2:35 pm)
It should be in main.cs in your T2D project root directory, or "example" directory, depending how your layout.
#16
09/10/2005 (3:04 pm)
Thanks for the quick response.

Also, I just ran Gold Fever. Windows Task manager is reporting 136mb under memory usage. I'm so confused :(
#17
09/10/2005 (3:11 pm)
@Christopher- don't worry about it; Gold Fever probably uses less memory than Doom-Nukem-3D-Deathmatch-3000 (or whatever)
:-)
#18
09/11/2005 (6:07 am)
It's better to be Zen-like and just let Torque do its work. I spent some time creating a font glyph pool manager so that it would "minimize" allocations, but it turned out to be no better than just allocating/deallocating each time and letting Torque manage memory for me.

So don't fight the system, just be responsible with your deallocations and forget the details. It's very nice once you accept this. :)