Get the latest tech news

Garbage collected smart pointers in Rust via concurrent cycle collection


heme to the Spec is a series on the more complex, often overlooked aspects of programming language implementation. In this series we will dive deep into my work-in-progress implementation of R6RS scheme, scheme-rs, an implementation designed to integrate seamlessly with the async-rust ecosystem.

Ten years ago I wrote an article on how to implement a conservative garbage collector for C, and I got a lot of constructive criticism regarding the actual usefulness of the code presented. Practically, this works by performing a depth first search on the root, marking each node gray and decrementing the reference count of each child and repeating the process on them. Because we are building our garbage collector on top of a system that already supports reference counted smart pointers, we can use an Arc to analyse the operation of our collection algorithms.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Rust

Rust

Photo of garbage

garbage

Photo of Smart Pointers

Smart Pointers

Related news:

News photo

Rust’s Incremental Compiler Architecture

News photo

NonStop discussion around adding Rust to Git

News photo

The humble for loop in Rust