Class: HeapScope::Runtime::TruffleRuby

Inherits:
Base
  • Object
show all
Defined in:
lib/heapscope/runtime/truffleruby.rb

Overview

Placeholder adapter — TruffleRuby support may expand later.

Instance Attribute Summary

Attributes inherited from Base

#engine

Instance Method Summary collapse

Methods inherited from Base

#allocation_info, #allocation_tracing?, #gc_stat, #gc_stat?, #process_metadata, #reachable_objects?, #reachable_objects_from, #rss_bytes, #rss_tracking?, #start_allocation_tracing, #stop_allocation_tracing

Constructor Details

#initializeTruffleRuby

Returns a new instance of TruffleRuby.



9
10
11
# File 'lib/heapscope/runtime/truffleruby.rb', line 9

def initialize
  super(engine: "truffleruby")
end

Instance Method Details

#each_object(klass = nil) ⇒ Object

Raises:



21
22
23
24
25
26
27
28
29
# File 'lib/heapscope/runtime/truffleruby.rb', line 21

def each_object(klass = nil, &)
  raise CapabilityError, "ObjectSpace.each_object unavailable on TruffleRuby" unless each_object?

  if klass
    ObjectSpace.each_object(klass, &)
  else
    ObjectSpace.each_object(&)
  end
end

#each_object?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/heapscope/runtime/truffleruby.rb', line 13

def each_object?
  defined?(ObjectSpace) && ObjectSpace.respond_to?(:each_object)
end

#memsize?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/heapscope/runtime/truffleruby.rb', line 17

def memsize?
  defined?(ObjectSpace) && ObjectSpace.respond_to?(:memsize_of)
end

#memsize_of(object) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/heapscope/runtime/truffleruby.rb', line 31

def memsize_of(object)
  return nil unless memsize?

  ObjectSpace.memsize_of(object)
rescue StandardError
  nil
end