Should I clear textures before overwriting?

Blitz3D Forums/Blitz3D Programming/Should I clear textures before overwriting?

Shifty Geezer(Posted 2006) [#1]
For my UI I use textured quads and a texture field in my object. To change the button I load a new pic (button\texture = LoadTexture("") )

Should I FreeTexture() before overwriting? I'm pretty sure the answers yes...


sswift(Posted 2006) [#2]
Yes, if you load a texture, and then stick the pointer into button\texture, then before you load a new texture and stick the pointer to that one into button\texture, you should free the old texture, or else you will have a texture in memory which is taking up space, and no pointer to it so that you can free it at a later time.

Blitz will free up whatever you don't when your program ends, but if your program runs for a while and you keep doing this, you will have what is called a memory leak... More and more ram getting filled up with useless data that you never free, and eventually you might run out of ram and possibly crash the system, or at least, your system will slow down until you end the program.


OJay(Posted 2006) [#3]
hm...i thought even blitz3d had an internal garbage-collector, that free's up memory, if there's no handle/pointer to a ressource anymore?