Game Development Community

ClearTextureHolds

by James Spellman · in Torque Game Engine · 11/21/2005 (3:19 pm) · 4 replies

This is one of those androgynous methods. It appears to want to find held textures with zero references so that they may be freed:

S32 TextureDictionary::clearHolds()
{
   Vector<TextureObject *>    holds;

   // Find held textures to delete.  Clear holding flag too so they're free
   // to go away.
   for (TextureObject * walk = smTOList; walk; walk = walk->next)
      if (walk->holding)
         if (!walk->refCount)
            holds.push_back(walk);
         else
            walk->holding = false;

   // Remove them-
   for (S32 i = 0; i < holds.size(); i++)
      TextureManager::freeTexture(holds[i]);

   return holds.size();
}

In fact, it frees all textures with zero references and clears the holding flag on everything else. As this method is called upon in disconnect code just prior to PurgeResources, I believe it is being used for its side-effect and not for its original purpose as indicated by the comments.

I think that clearing the holding flag was introduced to help the function of PurgreResouces, although it is not clear to me that the holding flag would have any bearing on the function of that routine. If the purpose was to dispose of all textures, the dispose method would work. If it was to clear out the holding flag, why bother with the zero reference files as they will obviously be removed when the held textures reach zero references.

The third option is that I'm insane, but I did reduce my memory footprint from 450MB down to 100MB.

#1
11/21/2005 (4:26 pm)
Sounds interesting.
what exactly was it you did, now ?
#2
11/23/2005 (9:34 am)
I have about 40 high-poly character models and complex interiors that if loaded simultaneously would be about 600MB, so I've been working on loading just what I need per mission (location or lighting changes mainly - "later that day..."). The problem has been unloading what I no longer need which the engine seems reluctant to do. My project is more like an adventure game than a FPS, so a lot of my needs don't coincide with the default architexture, and so I run into a lot of little things like the above issue.
#3
02/27/2006 (12:19 pm)
Can we get an official GG ruling on this?
#4
02/27/2006 (10:27 pm)
I'm a little unclear on what you're asking - the post seems like a great explanation of what the functions do, with some speculation as to their history... Can you restate the question more directly? :)