We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Decrement and free

Now things are going to get a touch more complicated. In a refcounting GC, the interesting stuff happens when the refcount equals 0. That's when the garbage gets collected.

When the refcount reaches 0, there are no references to this object anymore! So, we need to free the memory automagically -- that's the whole point of a garbage collector.

For our first pass at this, we will only handle integers, floats and strings to keep things simple. As we go a little further, we'll implement it for the rest of the SnekObject types.

Assignment