Okay so I went for a walk and I thought about the garbage collector on my walk and I want to start by specifying the goals of what I actually want and how it acts:

The garbage collector will have a cycle bit and each object will have a cycle bit. If the cycle bit matches then that means the object was not yet traversed during garbage collection, but if it does not match then it was. All allocations that happen will be set to the current cycle bit. As a note other objects are reference count increased first before the old one is decreased so no objects are lost ever.

It would be nice to have implicit object sizes though, like using a logarithmic or exponential scale. That way size can be encoded in the object data as needed.


With 2048 different size values, a full 31-bit range is with the following algorithm:

Also, regions which are in the free state free do not need a reference count they can pretty much be:


I would need a linked list of free chunks if I want to allocate certain objects at the ends.