Blitz3D garbage collection

Blitz3D Forums/Blitz3D Programming/Blitz3D garbage collection

RifRaf(Posted 2009) [#1]
How does Blitz3D handle unused textures? I can load a level with many textures, free the entity, load another level that has a same named texture(but not the same data) and Blitz3D references the old texture, so it would seem it never released it.

Is there a way to force blitz to release a texture reference from memory when the entity holding it is freed ?

The reason this is important to me, is that I will have user created maps, and it is likely that while each map will have its own filepath, the creators may create same named textures. I just dont see any way to force textures to be released. I cannot even use freetexture , ive tried that and it still references the old texture when reloading.

If the garbage collection is only say.. once every x minutes thats ok, but an InitGarbageCollection() call would be nice to have in that case.


Ross C(Posted 2009) [#2]
I've always found it odd the way it works. Like yourself, I found blitz always seems to keep the textures in memory, till either they are flushes out by other textures needing the VRAM space, or the clearworld command is called(i'm not doubly sure about clearworld actually doing this though).


RifRaf(Posted 2009) [#3]
Yeah, its weird. Clearworld isnt an option for me as I have other textures that are resident at all times that I cannot remove.

can anyone with the sdk comment on the gc ?


Bobysait(Posted 2009) [#4]
Most of the textures are assigned to shared brush. And the brushes aren't released until a clearworld

It prevent overloading, but force ram to keep the same as you free entities, brushes or textures, but the memory space is "re"allocated.
So you don't "eat" more ram.

Entities aren't really cleared too +> peek bytes of memory after a Free, you 'll see that most objects are still there. they just aren't linked anymore, and the memory space is declared "available" until it is reused.

b3d sdk do the same as far as I know. It's one of the first thing I've seen, when I free entities, the memory just doesn't change of a bit.


RifRaf(Posted 2009) [#5]
Bobysait,

thanks. this *seems* to work without any adverse side effects, on each map "unload" i simply call
Clearworld(0,1,0) ; <--0,1,0 only clears brushes

on the next map, the same named texture can be loaded from a differnt path and the updated texture data is shown as expected.

I do not know if there are internal issues using this method. I am using sprite candy as well , and none of its drawing operations seem to be effected.