https://jingling.im/posts/gc-algorithm/