Noob Bmax GC and Entity

Archives Forums/Blitz3D SDK Programming/Noob Bmax GC and Entity

H&K(Posted 2007) [#1]
If I dont keep an instance of a handle for any of the entities, are the Entities GCed? Or do I implicitly have to (bb)free them?

If I do have to free them, and if I havent kept an instance of their handle, and If the SDK doesnt keep an "Eachin" list.... then how do I reaquire the handle of a previously created entity?

Or is it that I should basicly always keep an instance of the Handle?

(Sorry if this seems very similar to my previous question)


ziggy(Posted 2007) [#2]
I think Blitz3dSDK is not a managed library so you have to free all entities. I would recomend you to manage them using a class.
something like
Type Tentity
    Field entity:Int
    Method Delete()
        if entity<> 0 then 
            bbFreeEntity entity
            entity = 0
    end Method
End Type


and store all entities on instances of this class, so when then class is Collected, the entitie is free. You can call the delete method 'by hand' if you want to free an antity before the gc collector calls the delete method of the class.


H&K(Posted 2007) [#3]
Lol @ Ziggy http://www.blitzmax.com/codearcs/codearcs.php?code=2031

I totaly forgot to add Delete Methods doh

Anyway, what about surfaces? If I attach a surface to a Mesh, then free the Mesh. Is the surface freed? Or conversly, if I free a surface after Ive attahed it to a mesh, has the surface become part of the Mesh so isnt freed?

Etc

(I can see that a brush copies its information to a surface/entity/mesh, so is safe to delete after use, but its not clear at all what happens to surfaces)


Gabriel(Posted 2007) [#4]
Surfaces are part of the mesh. If you delete them, they're gone. If you delete the ( only ) mesh that uses them, they're gone. If you make shallow copies of the mesh then I guess they're held until the last copy is destroyed because shallow copies are referencing the original mesh data. Either way, you don't really have to think about it. If you specifically want them gone, you can make them gone, and if you don't do anything, they'll be removed when the time comes anyway.