From: eregontp@... Date: 2019-10-08T19:28:10+00:00 Subject: [ruby-core:95282] [Ruby master Feature#16245] Add interfaces to count and measure size all IMEMO objects Issue #16245 has been updated by Eregon (Benoit Daloze). Do you think it would be possible for this new API to not rely on whether there is bytecode/iseqs? That way, it could be implemented on other Ruby implementations. Is the main purpose to be able to estimate memory used by loaded Ruby code (methods)? A count of reachable methods' internal representations (iseq, AST, etc) would be a metric that is likely easy to provide work for all Ruby implementations. ---------------------------------------- Feature #16245: Add interfaces to count and measure size all IMEMO objects https://bugs.ruby-lang.org/issues/16245#change-81960 * 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: