Game Development Community

Deleting GUIs does not always delete them?

by Dave Calabrese · in iTorque 2D · 12/20/2009 (7:54 am) · 4 replies

In working out some memory cleanup of our project, I took a real close look at the dumpTextureStats(), and realized that numerous GUI graphics were still in memory. What I found weird about this, were that the GUIs had already been deleted! I ran a number of tests, and found that myGui.delete(); would work - sometimes. In the exact same situations, the engine would sometimes just not delete the GUI, and keep its images in memory.

I came up with a rather temporary and ugly solution for the time being, however I'm curious if other people are seeing this problem as well. If so, it's a pretty serious memory leak.

Here's my stopgap solution:

function superDelete(%objName)
{
  while(isObject(%objName))
  {
      %objName.delete();
  }
}

#1
12/20/2009 (10:15 am)
does your regular removal code use delete or safedelete?
#2
12/20/2009 (10:25 am)
Delete. Safedelete never seems to work on GUIs, however delete would delete them occasionally, so I relied on that.
#3
12/20/2009 (10:56 am)
Sounds like an image reference issue. In the cases where you don't appear to see the GUI being deleted, can you step in and see why? Is it when the textures are removed? Perhaps they have larger reference counts? Perhaps they are set to be *preloaded*, and then the refcount is wonky in that case?

I also found a bug in in t2dTextObjects that would load a font. When the object was then deleted, the font(s) would stay around in memory and not be removed (not even have their refcounts decremented). This has been fixed for the next version. That could possibly be what you are seeing?
#4
12/20/2009 (5:15 pm)
In TGB, you can have multiple objects with the same name. You may find that you have controls with duplicate names somewhere in your GUI files which would explain the issue.