This issue was solved with changeset r43585.
Aman, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
ext/objspace/object_tracing.c: Add experimental methods to dump
objectspace as json: ObjectSpace.dump_all and ObjectSpace.dump(obj).
These methods are useful for debugging reference leaks and memory growth
in large ruby applications. [Bug #9026] [ruby-core:57893] [Fixes GH-423]