From: ko1@... Date: 2019-10-16T05:52:34+00:00 Subject: [ruby-core:95353] [Ruby master Feature#16245] Add interfaces to count and measure size all IMEMO objects Issue #16245 has been updated by ko1 (Koichi Sasada). Already we have: ```ruby require 'objspace' pp ObjectSpace.count_imemo_objects #=> {:imemo_env=>42, :imemo_cref=>177, :imemo_ment=>3662, :imemo_iseq=>1194, :imemo_tmpbuf=>117, :imemo_ast=>22, :imemo_svar=>40, :imemo_throw_data=>55, :imemo_ifunc=>35, :imemo_memo=>32, :imemo_parser_strterm=>118} ``` There is no size version. do you want to introduce it? ---------------------------------------- Feature #16245: Add interfaces to count and measure size all IMEMO objects https://bugs.ruby-lang.org/issues/16245#change-82061 * Author: sam.saffron (Sam Saffron) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- Koichi introduced an experimental gem: https://github.com/ko1/iseq_collector It allows: ObjectSpace.each_iseq{|iseq| ...} ObjectSpace.count_iseq #=> Integer ObjectSpace.memsize_of_all_iseq (should not generate RubyVM::InstructionSequence wrappers for IMEMOs) Since the wrapper object RubyVM::InstructionSequence is lazily allocated, ObjectSpace.each_object does not find these IMEMOs unless they have been wrapped. This design is good and conserves memory. `count_iseq` and `memsize_of_all_iseq` are very powerful metrics most large Ruby deployments can use to automatically detect method leaks introduced via meta programming. These issues are invisible now short of walking a heap dump. Can we add the new interface into 2.7? -- https://bugs.ruby-lang.org/ Unsubscribe: