

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 10
click for more info
Not enough gems
Cost: 6 gems
1: Garbage Collector
incomplete
2: Refcounting
incomplete
3: Increment
incomplete
4: Decrement and free
incomplete
5: Vectors
incomplete
6: Arrays
incomplete
7: Refcounting Review
incomplete
This lesson's interactive features are locked, please to keep using them
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.