• Advertisement
Sign in to follow this  

Cleanup Confusion

This topic is 4403 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have some block objects that I need to get rid of when a row is complete in my tetris remake. I know to set them to "null", but how do I completely remove an instance of a class from existence?

Share this post


Link to post
Share on other sites
Advertisement
In this case, they will automatically get cleaned up, once you have totally stopped using them. This is called "garbage collection" and it makes things a lot easier.

As soon as all references to an object are gone, it gets garbage collected. Any time you pass an object to a function, place it in an array, etc. a reference gets created. (Note that, when calling a function, the reference is cleaned up automatically when the function returns, so you don't have to worry about that.) All you need to do is make sure that each reference is removed, and the object will be cleaned up for you.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement