Memory management
by Laralyn McWilliams · in Torque Game Builder · 05/29/2010 (11:01 pm) · 2 replies
I'm working on a fairly image-intensive project, but it seems like the memory use while the game is running is out of proportion with the size of the assets. Here's what I've done so far:
When I started looking at memory, the game was using about 420 MB of RAM.
I checked the size of the actual images, and the entire image folder is 40 MB.
I re-sized the images that make up the bulk of that 40 MB so that they are 1024X512 (power of 2).
I did an image dump and all the dumped image files only totaled 8 MB, and I didn't see anything I didn't expect.
I set ALL images to not preload and to unload, since I was willing to take the performance hit if it helped memory, and it did nothing.
I set all the images to 16 bit, and it did nothing.
I ran the .exe without the builder, and it still used about 420 MB.
I'm starting to think my images aren't the issue. :-)
I'm really new to TGB, and not sure what else could eat so much memory. Is there some kind of profiling I can turn on in the app, or another way I can see what's using memory? Are there any usual suspects I should be checking?
Thanks!
When I started looking at memory, the game was using about 420 MB of RAM.
I checked the size of the actual images, and the entire image folder is 40 MB.
I re-sized the images that make up the bulk of that 40 MB so that they are 1024X512 (power of 2).
I did an image dump and all the dumped image files only totaled 8 MB, and I didn't see anything I didn't expect.
I set ALL images to not preload and to unload, since I was willing to take the performance hit if it helped memory, and it did nothing.
I set all the images to 16 bit, and it did nothing.
I ran the .exe without the builder, and it still used about 420 MB.
I'm starting to think my images aren't the issue. :-)
I'm really new to TGB, and not sure what else could eat so much memory. Is there some kind of profiling I can turn on in the app, or another way I can see what's using memory? Are there any usual suspects I should be checking?
Thanks!
#2
The main level performs this function at the beginning and end of each game:
The sector class has this function:
Every game object is created dynamically and added to the contents SimSet of its respective sector as it is created.
Hope this helps!
05/31/2010 (10:04 am)
Fangorodrim takes up abut 140 megs and never goes above that. I started this project from day one with object cleanup functions.The main level performs this function at the beginning and end of each game:
function GlobalLevel::CleanUpQuadrant(%this)
{
echo("...........CleanUpQuadrant..........");
if (isObject($sector[0])){
for (%n=0;%n<%this.sectorCnt;%n++){
$Sector[%n].DeleteContents();
$Sector[%n].safeDelete();
}
}
}The sector class has this function:
function SectorLevel::DeleteContents(%this)
{
if (isEventPending(%this.musicID)) cancel(%this.musicID);
if (isEventPending(%this.bigID)) cancel(%this.bigID);
if (isEventPending(%this.smallID)) cancel(%this.smallID);
if (isEventPending(%this.spawnID)) cancel(%this.spawnID);
if (isEventPending(%this.warpEventID)) cancel(%this.warpEventID);
if (isEventPending(%this.hideID)) cancel(%this.hideID);
if (isEventPending(%this.scoreID)) cancel(%this.scoreID);
if (isObject(%this.contents)){
while(%this.contents.getCount()){
%obj=%this.contents.getObject(0);
if (strlen(%obj.class)>0) %obj.cancelSchedules();
%Obj.Delete();
}
%this.contents.Delete();
}
}Every game object is created dynamically and added to the contents SimSet of its respective sector as it is created.
Hope this helps!
Torque Owner Laralyn McWilliams