Game Development Community

GuiControl SetBitmap - memory leak until crash

by Vladan Markovic · in Torque Game Builder · 12/06/2011 (1:23 pm) · 2 replies

Hi,

I have a lot of GuiControl (GuiBitmapControl) in which i dynamically change bitmap,
now it seems that there is no way to release old bitmap when setting new ones in control.

For example: (

new GuiBitmapCtrl(transitionBG) { ... };

transitionBG.Bitmap=(%imgStc1); // %imgStc`s are huge fullscreen bitmaps
Task Manager shows: TorqueGameBuilder: 100mb

transitionBG.Bitmap=(%imgStc2);
Task Manager shows: TorqueGameBuilder: 150mb

transitionBG.Bitmap=(%imgStc3);
Task Manager shows: TorqueGameBuilder: 200mb

etc ... until it crash with system Low Memory error.

I looked at the engine code, the function that is called is:
mTextureHandle = TextureHandle(mBitmapName, BitmapTexture, true);

Which creates new texture in memory if don't exist, or get existing one if it finds it,

I cant find function to release bitmap handles that i do not need anymore before i load new one.
Something like:

transitionBG.DestroyOldTexture(); //delete existing texture handle
transitionBG.Bitmap = (%imgStc3); // create new texture handle

This is major problem in our current game design, please help.


Thank You.





#1
12/07/2011 (12:26 am)
purgeResources() should delete every unused resource, including textures, sounds and whatever else resource manager is tracking. clearTextureHolds() from what I see should delete all unreferenced textures, but I've never used it before. dumpTextureStats() might also come in handy.
#2
12/08/2011 (9:20 am)
Thank you,
That worked.