I am using classes for my app and I have a quick question. I have a class called bullet which I can call using Bullet.new() and store into a variable for reference. However, I made it so that the class takes care of itself and I really do not need an outside reference to it. I have tested with a blank Lua file calling my class using Bullet.new() but NOT storing it to a variable. Within the class I have a timer that removes the bullet from the stage and sets self = nil after 60 frames. I monitored texture memory and lua memory and there are no leaks and everything is properly collected. Is this safe practice?
Comments
Bullet will not be collected while added to the stage, and once you remove it, it has no references and will be collected. So everything should be ok.