Delete?

BlitzMax Forums/BlitzMax Beginners Area/Delete?

Craig H. Nisbet(Posted 2007) [#1]
What's the blitz max equivalent to Delete in Blitz 3D? How do a delete a type instance after I've created it in Max?


tonyg(Posted 2007) [#2]
You don't. When the last variable accessing goes out of scope it is set as available for deletion and auto-GC does the rest.


Craig H. Nisbet(Posted 2007) [#3]
what? I'm not sure if we're talking about the same thing.

if I had a type defined for a bullet and I created one in the game world and wanted it to last for 1 second, then delete the type instance from memory, how would I do that?


tonyg(Posted 2007) [#4]
I think we are!
You would let the variable got out of scope and remove it from any list. You could null the variable pointer to make sure.
When there is no longer a reference to your bullet it is auto-deleted the next time Grabage collection is run.


Sledge(Posted 2007) [#5]
Yeah, what would cause a memory leak in B3D is the way you're supposed to do things in Max.


Czar Flavius(Posted 2007) [#6]
You will probably store the bullets in a TList. Simply use a remove method on the bullet when you want to get rid of it. Provided it is not referenced elsewhere, Blitz will automatically delete the bullet for you.


Craig H. Nisbet(Posted 2007) [#7]
Ah, I get it. I didn't know there was a remove method.


Craig H. Nisbet(Posted 2007) [#8]
wait, so if I do something like this?

local guy:player = new player
guy = new player


the second instance will get created and the first one will just disappear from memory?


Jesse(Posted 2007) [#9]
you have seen the light. :)