ImageMap Memory Management
by Warthog · in Torque Game Builder · 07/02/2008 (3:08 pm) · 5 replies
I am working on a game that has a large number of characters on a long linear road (think ala "The Simpsons" videogame of the early 1990's). I built the background as a series of 256x256 pixel blocks in a tile map (147 blocks long and 2 blocks high). The characters (which have a number of complex actions requiring decently large imagemaps) are being placed using the Level editor on the road. The camera follows the main character as he walks down the road and encounters enemies.
When I go to play the game, it performs very jerky as if it's having problems loading and unloading the imagemaps. When I look at the memory usage in the Windows Task Manager, it seems to only be using about 30 megs of RAM which doesn't seem like much to me. I don't get the feeling that I'm pushing the machine very strenuously despite what's happening.
Are there some memory management techniques that people have found useful? How does TGB's memory management work? Are there ways to limit what gets loaded when? I've read the TDN article about "2D Art Tips: Learn from my mistakes" which definitely had some great ideas but I still have my jerky movement issues.
HELP!! Is anyone else having similar problems?
Thanks,
Shawn
When I go to play the game, it performs very jerky as if it's having problems loading and unloading the imagemaps. When I look at the memory usage in the Windows Task Manager, it seems to only be using about 30 megs of RAM which doesn't seem like much to me. I don't get the feeling that I'm pushing the machine very strenuously despite what's happening.
Are there some memory management techniques that people have found useful? How does TGB's memory management work? Are there ways to limit what gets loaded when? I've read the TDN article about "2D Art Tips: Learn from my mistakes" which definitely had some great ideas but I still have my jerky movement issues.
HELP!! Is anyone else having similar problems?
Thanks,
Shawn
#2
Thanks for the help!
Shawn
07/02/2008 (5:42 pm)
They are mostly unique although I've played with preloading and unloading and it seems as though TGB does not effectively kill the imageMaps after they have left the screen or perhaps load too many before they are needed. The game doesn't move all that fast. Do you know if TGB will load up as much stuff as possible and just hold onto it, or does it pay attention to the camera window and only preload and unload stuff around it? The latter seems reasonable but I'm in the dark as to what TGB tries to keep in memory. Any ideas?Thanks for the help!
Shawn
#3
07/03/2008 (9:12 am)
I have read in the forums previously that if you are judging whether TGB is unloading images via looking at the windows task manager you will not see the overall app memory usage go down because torque does not ever return memory back to the system, it keeps it around for later so it does not have to go through the "request memory from os" process.
#4
I guess my bigger question is how TGB uses memory in regards to imagemaps. Does it load only the imagemaps close to the camera window or does it try to load as much as possible and keep it in memory for later? I also tried laying out my level in the level editor and using no tilemaps thinking that might help some too, but TGB still seems to be overextending itself and loading things with somewhat odd timing. Any insight?
Shawn
07/03/2008 (9:52 am)
@James: Good to know about the Windows Task Manager. Thanks! When I run it on my Mac with the activity monitor, I get a MUCH higher number that I think more accurately reflects the memory usage. I guess my bigger question is how TGB uses memory in regards to imagemaps. Does it load only the imagemaps close to the camera window or does it try to load as much as possible and keep it in memory for later? I also tried laying out my level in the level editor and using no tilemaps thinking that might help some too, but TGB still seems to be overextending itself and loading things with somewhat odd timing. Any insight?
Shawn
#5
Something to understand here is the difference between loading an image into RAM, and loading into onto VRAM. All images marked preload will be loaded into RAM at game start-up. Possibly VRAM too, I'm not sure. The thing is, there is only a limited amount of VRAM, and I'm quite certain from the dimensions you've described, you're *way* exceeding your graphics card's VRAM capacity. This means that images constantly have to be swapped in and out of VRAM as you scroll, which is killing performance.
To solve this, you'll need to dramatically cut down on both the resolution of your tiles, and how many there are, in terms of unique tiles. Reuse a lot of them. This may require coming up with a new solution.
One problem with programming in Torque is that the engine will let you do stupid stuff without the programmer realizing it's stupid. Like using many huge images that will never fit into VRAM all at once. We're so far from the engine's core that we don't realize how much it'll kill performance when we do what we're planning on doing. I've learned this the hard way.
07/07/2008 (12:42 pm)
Warthog,Something to understand here is the difference between loading an image into RAM, and loading into onto VRAM. All images marked preload will be loaded into RAM at game start-up. Possibly VRAM too, I'm not sure. The thing is, there is only a limited amount of VRAM, and I'm quite certain from the dimensions you've described, you're *way* exceeding your graphics card's VRAM capacity. This means that images constantly have to be swapped in and out of VRAM as you scroll, which is killing performance.
To solve this, you'll need to dramatically cut down on both the resolution of your tiles, and how many there are, in terms of unique tiles. Reuse a lot of them. This may require coming up with a new solution.
One problem with programming in Torque is that the engine will let you do stupid stuff without the programmer realizing it's stupid. Like using many huge images that will never fit into VRAM all at once. We're so far from the engine's core that we don't realize how much it'll kill performance when we do what we're planning on doing. I've learned this the hard way.
Torque Owner Vern Jensen
I'm pretty sure the 30 MB figure you're seeing is not correct. Not sure why, as I don't do Windows, but typically the number is in the hundreds, for even a fairly simple game.