Sign in to follow this  
Grantyt3

Cleanup Confusion

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this