Setting TImage To Null?

BlitzMax Forums/BlitzMax Beginners Area/Setting TImage To Null?

MGE(Posted 2008) [#1]
What does setting a TImage object to null do? I'd like a way to remove the resource completely when it's not needed anymore and if possible remove it from video memory as well. Thanks.


plash(Posted 2008) [#2]
I don't know about video memory stuff, but setting the image to null should start the GC on it.


tonyg(Posted 2008) [#3]
... you would also have to remove it from any lists, arrays etc


GfK(Posted 2008) [#4]
Anything that goes out of scope, gets picked up by garbage collection and can't be used any more.


Grey Alien(Posted 2008) [#5]
Yeah, setting to null (if that's the last pointer, so it's not in any arrays, lists, global/local variables etc) will kill it off when the GC next collects. But it won't kill it from VRAM. I sometimes use it to clean out memory when I change screens or something. However, often it's not needed like if you have a TImage field on a type, when the type is killed, the TImage is automatically killed too. (same with sounds but NOT the same with TChannels)

There is a way to precache images in VRAM. So rather than killing out old ones, I just make sure the ones for the current screen are precached before the first draw. If the VRAM is small, the card should automatically overwrite the older textures.

Maybe there are fancy DX/OGL commands to kill out textures from VRAM.