Ruby バージョン別GC.stat()の値

# Ruby バージョン別 GC.stat()
RubyのGC.stat()は、バージョンごとに返ってくる値が違うため、差分をまとめました。
2017-12-26 Ruby2.5追加

# Ruby 2.0
RubyにGCが導入されました。GC.stat()は非常にシンプルな値しか返しません。

```shell-session
$ ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [x86_64-linux]
$ ruby -r json -e 'print JSON.dump(GC.stat())' | jq .
{
"count": 4,
"heap_used": 77,
"heap_length": 77,
"heap_increment": 0,
"heap_live_num": 13071,
"heap_free_num": 21512,
"heap_final_num": 0,
"total_allocated_object": 48497,
"total_freed_object": 35426
}
```

# Ruby 2.1
詳細な情報が追加されました。

```shell-session
$ ruby -v
ruby 2.1.10p492 (2016-04-01 revision 54464) [x86_64-linux]
$ ruby -r json -e 'print JSON.dump(GC.stat())' | jq .
{
"count": 5,
"heap_used": 75,
"heap_length": 81,
"heap_increment": 6,
"heap_live_slot": 29819,
"heap_free_slot": 752,
"heap_final_slot": 0,
"heap_swept_slot": 3861,
"heap_eden_page_length": 75,
"heap_tomb_page_length": 0,
"total_allocated_object": 48629,
"total_freed_object": 18810,
"malloc_increase": 1076728,
"malloc_limit": 16777216,
"minor_gc_count": 3,
"major_gc_count": 2,
"remembered_shady_object": 151,
"remembered_shady_object_limit": 300,
"old_object": 5842,
"old_object_limit": 11684,
"oldmalloc_increase": 1077176,
"oldmalloc_limit": 16777216
}
```

# Ruby 2.2
単数形が複数系になり、bytesなどの単位がつき、表現が丁寧になっています。
`heap_marked_slots`が追加されています。 

```shell-session
$ ruby -v
ruby 2.2.8p477 (2017-09-14 revision 59906) [x86_64-linux]
$ ruby -r json -e 'print JSON.dump(GC.stat())' | jq .
{
"count": 5,
"heap_allocated_pages": 74,
"heap_sorted_length": 75,
"heap_allocatable_pages": 0,
"heap_available_slots": 30165,
"heap_live_slots": 29204,
"heap_free_slots": 961,
"heap_final_slots": 0,
"heap_marked_slots": 8805,
"heap_swept_slots": 7197,
"heap_eden_pages": 73,
"heap_tomb_pages": 1,
"total_allocated_pages": 74,
"total_freed_pages": 0,
"total_allocated_objects": 50243,
"total_freed_objects": 21039,
"malloc_increase_bytes": 152840,
"malloc_increase_bytes_limit": 16777216,
"minor_gc_count": 3,
"major_gc_count": 2,
"remembered_wb_unprotected_objects": 156,
"remembered_wb_unprotected_objects_limit": 278,
"old_objects": 7418,
"old_objects_limit": 10932,
"oldmalloc_increase_bytes": 153288,
"oldmalloc_increase_bytes_limit": 16777216
}
```

# Ruby 2.3
2.2と2.3の間の差異はありません。

```shell-session
$ ruby -v
ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-linux]
$ ruby -r json -e 'print JSON.dump(GC.stat())' | jq .
{
"count": 6,
"heap_allocated_pages": 74,
"heap_sorted_length": 75,
"heap_allocatable_pages": 0,
"heap_available_slots": 30163,
"heap_live_slots": 29730,
"heap_free_slots": 433,
"heap_final_slots": 0,
"heap_marked_slots": 12904,
"heap_swept_slots": 1911,
"heap_eden_pages": 74,
"heap_tomb_pages": 0,
"total_allocated_pages": 74,
"total_freed_pages": 0,
"total_allocated_objects": 63670,
"total_freed_objects": 33940,
"malloc_increase_bytes": 54520,
"malloc_increase_bytes_limit": 16777216,
"minor_gc_count": 4,
"major_gc_count": 2,
"remembered_wb_unprotected_objects": 180,
"remembered_wb_unprotected_objects_limit": 284,
"old_objects": 10673,
"old_objects_limit": 13836,
"oldmalloc_increase_bytes": 631032,
"oldmalloc_increase_bytes_limit": 16777216
}
```

# Ruby 2.4
`heap_swept_slots`が削除されました。

```shell-session
$ ruby -v
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]
$ ruby -r json -e 'print JSON.dump(GC.stat())' | jq .
{
"count": 8,
"heap_allocated_pages": 65,
"heap_sorted_length": 65,
"heap_allocatable_pages": 0,
"heap_available_slots": 26494,
"heap_live_slots": 26269,
"heap_free_slots": 225,
"heap_final_slots": 0,
"heap_marked_slots": 11738,
"heap_eden_pages": 65,
"heap_tomb_pages": 0,
"total_allocated_pages": 65,
"total_freed_pages": 0,
"total_allocated_objects": 66208,
"total_freed_objects": 39939,
"malloc_increase_bytes": 105872,
"malloc_increase_bytes_limit": 16777216,
"minor_gc_count": 7,
"major_gc_count": 1,
"remembered_wb_unprotected_objects": 165,
"remembered_wb_unprotected_objects_limit": 286,
"old_objects": 10929,
"old_objects_limit": 14302,
"oldmalloc_increase_bytes": 1351056,
"oldmalloc_increase_bytes_limit": 16777216
}
```
# Ruby 2.5
2.4と変わりません

```shell-session
$ ruby --version
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux]
$ ruby -r json -e 'print JSON.dump(GC.stat())' | jq .
{
  "count": 9,
  "heap_allocated_pages": 51,
  "heap_sorted_length": 51,
  "heap_allocatable_pages": 0,
  "heap_available_slots": 20787,
  "heap_live_slots": 20653,
  "heap_free_slots": 134,
  "heap_final_slots": 0,
  "heap_marked_slots": 13983,
  "heap_eden_pages": 51,
  "heap_tomb_pages": 0,
  "total_allocated_pages": 51,
  "total_freed_pages": 0,
  "total_allocated_objects": 51323,
  "total_freed_objects": 30670,
  "malloc_increase_bytes": 22368,
  "malloc_increase_bytes_limit": 16777216,
  "minor_gc_count": 7,
  "major_gc_count": 2,
  "remembered_wb_unprotected_objects": 196,
  "remembered_wb_unprotected_objects_limit": 348,
  "old_objects": 13386,
  "old_objects_limit": 24400,
  "oldmalloc_increase_bytes": 22824,
  "oldmalloc_increase_bytes_limit": 16777216
}
```

# Ruby 2.6
2.5と変わりません

```shell-session
$ ruby --version
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
$ ruby -r json -e 'print JSON.dump(GC.stat())' | jq .
{
  "count": 13,
  "heap_allocated_pages": 61,
  "heap_sorted_length": 61,
  "heap_allocatable_pages": 0,
  "heap_available_slots": 24862,
  "heap_live_slots": 18893,
  "heap_free_slots": 5969,
  "heap_final_slots": 0,
  "heap_marked_slots": 16573,
  "heap_eden_pages": 61,
  "heap_tomb_pages": 0,
  "total_allocated_pages": 61,
  "total_freed_pages": 0,
  "total_allocated_objects": 74957,
  "total_freed_objects": 56064,
  "malloc_increase_bytes": 103504,
  "malloc_increase_bytes_limit": 16777216,
  "minor_gc_count": 10,
  "major_gc_count": 3,
  "remembered_wb_unprotected_objects": 221,
  "remembered_wb_unprotected_objects_limit": 416,
  "old_objects": 15930,
  "old_objects_limit": 29470,
  "oldmalloc_increase_bytes": 103504,
  "oldmalloc_increase_bytes_limit": 16777216
}
```