This issue was solved with changeset r44059.
Aman, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
gc.c: promote long-lived NODE_CREF objects to oldgen
include/ruby/ruby.h: add RGENGC_WB_PROTECTED_NODE_CREF setting
In a large app, this reduces the size of
remembered_shady_object_count by 80%. [Bug #9225] [ruby-core:58947]
gc.c (rb_node_newnode): add FL_WB_PROTECTED flag to NODE_CREF
class.c (rewrite_cref_stack): insert OBJ_WRITE for NODE_CREF