With Ruby 1.9.1 being out for a while now, it's time to review my calculations regarding the memory footprint of objects, since 1.9 incorporates some optimizations that improve significantly on 1.8. I also measured the footprint of OCaml objects while I was at it.
This table summarizes the results (sizes in bytes on x86; around (exactly, for OCaml) twice as much on x86-64 --- the malloc overhead might differ):
Ruby 1.8
Ruby 1.9
OCaml
object with no IVs
20
20
12
object 1 IV
120
20
16
object 2 IVs
144
20
20
object 3 IV
168
20
24
object 4 IV
192
48
28
struct (Struct or record) 1 elm.
32
20
8
struct 2 elms.
36
20
12
struct 3 elms.
40
20
16
struct 4 elms.
44
44
20
Keep in mind that both Ruby 1.8 and 1.9 can suffer from heavy memory fragmentation (both internal and external) when allocating many objects (also, objects might be retained for an arbitrarily long amount of time because the GC is conservative). OCaml has no such problem, as it has got a generational, exact GC with a copying GC in the minor heap and an incremental mark & sweep & compact GC in the major heap.