Texture & Brush handles

Blitz3D Forums/Blitz3D Beginners Area/Texture & Brush handles

Moraldi(Posted 2008) [#1]
Is it a good practice to free any brush/texture handles after applying on entities?
I am asking because the only reason I can see not to destroy them is when I have animated textures or brushes created by animated textures.

Thanks!


Ross C(Posted 2008) [#2]
I would imagine freeing a texture, will get rid of it from memory and remove it from the entity. However, if it's not getting rid of it from the entity, then it still exists and there is no point in freeing it :o)

Another point with freeing resources i have found. For instance, if i copy entity CUBE mesh. Then i free the cube mesh, i would need to free every other instance of that to regain any memory. IE. copied entities don't take anymore memory up, and by freeing the entity that was used for copying, it still doesn't free the memory.

Any, that's besides the point. If you free a texture it won't exist anymore. Pretty pointless unless you don't want to use that texture anymore.

Regarding brushes, i'm not entirely sure whether blitz will retain the texture. I would imagine it would destroy all properties coupled with the brush.

Only reason to free a brush i have found, is after GetSurfaceBrush() and GetBrushTexture(). These commands create new brushes and textures, and should be freed when your finished working with them. The originals still exist though, it's just a way of accessing them.


Moraldi(Posted 2008) [#3]
Thanks Ross C.


jfk EO-11110(Posted 2008) [#4]
As far as I know Blitz is optimizing the usage of most things. For example texture, or sounds. If you load them twice, Blitz will load them only once internally, and create a link to the original for the second one. I guess the same goes for Brushes. There may also be some sort of garbage collection, so when a brush was deleted and is no longer used by any other surface, then and only then it will be removed from memory.