Skip to main content

赖洪礼的 blog » How the Ruby heap is implemented

Popularity Report

Total Popularity Score: 0

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Rank

Bookmark History

Saved by 4 people (2 private), first by anonymouse user on 2007-10-28


Public Sticky notes

All those types are actually child type of a single parent type: RBasic.

Since Ruby is written in C, the implementation doesn’t appear to be object oriented at first sight, even though it actually is (though in a very messy way, in my opinion). But let’s take a look how that’s implemented. This is how RClass and RFloat are defined:

Highlighted by harryli

Ruby uses a simple mark-and-sweep algorithm. It works as follows:

  1. Mark all objects that are accessible from the current point of the Ruby program (mark phase).
  2. Iterate through all objects and free those that are not marked (sweep phase).

Highlighted by harryli