Ruby 2.0 undefined method ObjectSpace.trace_object_allocations

tried this on ruby ​​2.0.0 / 247 or with my head:

require 'objspace' ObjectSpace.trace_object_allocations -> undefined method `trace_object_allocations' for ObjectSpace:Module 

The docs say it should work http://www.ruby-doc.org/stdlib-2.0/libdoc/objspace/rdoc/ObjectSpace.html any idea what I miss?

+4
source share
2 answers

Available only when installing aka ruby ​​2.1 ruby ​​head

+2
source

From the output of puts ObjectSpace.methods.sort after an objspace request, it looks like this method does not exist.

 irb(main):005:0> puts ObjectSpace.methods.sort ... reachable_objects_from remove_class_variable remove_instance_variable respond_to? send singleton_class singleton_methods taint tainted? tap to_enum to_s trust undefine_finalizer untaint untrust untrusted? => nil irb(main):009:0> ObjectSpace.methods.include? :trace_object_allocations => false 

You can see that it contains the ::reachable_objects_from method, which is mentioned in the docs, but not the one you are looking for, unfortunately.

0
source

Source: https://habr.com/ru/post/1493746/


All Articles