Delete?
BlitzMax Forums/BlitzMax Beginners Area/Delete?
| ||
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? |
| ||
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. |
| ||
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? |
| ||
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. |
| ||
Yeah, what would cause a memory leak in B3D is the way you're supposed to do things in Max. |
| ||
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. |
| ||
Ah, I get it. I didn't know there was a remove method. |
| ||
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? |
| ||
you have seen the light. :) |