Game Development Community

Loading and unloading GUIBitmapCtrls

by John F · in iTorque 2D · 03/22/2009 (2:22 am) · 2 replies

I need to reduce the amount of memory that my app is consuming. Using Instruments in XCode I was able to determine that each of my GUI dialogs (of which I have 12) is consuming a lot of memory at startup. These dialogs have GUIBitmapCtrls in them that reference large images. It was my understanding that these bitmaps would not be loaded until the dialog was displayed (using Canvas.PushDialog(MyDialog);) but this is not the case.

The bitmaps are not referenced in any datablocks. The only reference to them is in the GUIBitmapCtrls that were created by the GUI editor when I laid out the dialogs. I call exec() for each of the dialogs during initialization. Presumably the bitmaps are being read into memory at that time.

Is there a way to prevent the bitmaps from loading early and force them to unload when the dialog is no longer displayed? Should I defer the call to exec() until I am ready to show the dialog? If so, what call do I make to unload the dialog (or even just the bitmap) when it is no longer needed?

Thanks,
John

#1
03/23/2009 (5:59 am)
I am thinking of the same thing John, and am going to try execing and deleting the gui before and after, as I've got a mysterious object deletion bug which has cropped up. For what it's worth, without knowing how iTGB is really handling deallocs, it *should* work to delete the entire gui Object with one .delete() call, that *should* delete the objects and memory they are using.
#2
03/25/2009 (7:15 pm)
As a followup, this method gives a nice bit of memory back to the app and removed some of my leaking issues as well.