Class: HeapScope::Runtime::Base

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

Overview

Shared runtime adapter interface. Implementations degrade safely.

Direct Known Subclasses

JRuby, MRI, TruffleRuby

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(engine: RUBY_ENGINE) ⇒ Base

Returns a new instance of Base.



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

def initialize(engine: RUBY_ENGINE)
  @engine = engine
end

Instance Attribute Details

#engineObject (readonly)

Returns the value of attribute engine.



7
8
9
# File 'lib/heapscope/runtime/base.rb', line 7

def engine
  @engine
end

Instance Method Details

#allocation_info(_object) ⇒ Object



70
71
72
# File 'lib/heapscope/runtime/base.rb', line 70

def allocation_info(_object)
  nil
end

#allocation_tracing?Boolean

Returns:

  • (Boolean)


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

def allocation_tracing?
  false
end

#each_object(_klass = nil) ⇒ Object

Raises:



50
51
52
# File 'lib/heapscope/runtime/base.rb', line 50

def each_object(_klass = nil)
  raise CapabilityError, "ObjectSpace.each_object is unavailable on #{engine}"
end

#each_object?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/heapscope/runtime/base.rb', line 32

def each_object?
  false
end

#gc_statObject



40
41
42
43
44
# File 'lib/heapscope/runtime/base.rb', line 40

def gc_stat
  return {} unless gc_stat?

  normalize_gc_stat(GC.stat)
end

#gc_stat?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/heapscope/runtime/base.rb', line 36

def gc_stat?
  defined?(GC) && GC.respond_to?(:stat)
end

#memsize?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/heapscope/runtime/base.rb', line 21

def memsize?
  false
end

#memsize_of(_object) ⇒ Object



54
55
56
# File 'lib/heapscope/runtime/base.rb', line 54

def memsize_of(_object)
  nil
end

#process_metadataObject



74
75
76
77
78
79
80
81
82
83
# File 'lib/heapscope/runtime/base.rb', line 74

def 
  {
    pid: Process.pid,
    ppid: Process.ppid,
    engine: engine,
    ruby: RUBY_VERSION,
    platform: RUBY_PLATFORM,
    thread: Thread.current.name || Thread.current.object_id.to_s
  }
end

#reachable_objects?Boolean

Returns:

  • (Boolean)


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

def reachable_objects?
  false
end

#reachable_objects_from(_object) ⇒ Object



58
59
60
# File 'lib/heapscope/runtime/base.rb', line 58

def reachable_objects_from(_object)
  []
end

#rss_bytesObject



46
47
48
# File 'lib/heapscope/runtime/base.rb', line 46

def rss_bytes
  read_rss_bytes
end

#rss_tracking?Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
# File 'lib/heapscope/runtime/base.rb', line 25

def rss_tracking?
  rss_bytes
  true
rescue StandardError
  false
end

#start_allocation_tracingObject

Raises:



62
63
64
# File 'lib/heapscope/runtime/base.rb', line 62

def start_allocation_tracing
  raise CapabilityError, "Allocation tracing unavailable on #{engine}"
end

#stop_allocation_tracingObject



66
67
68
# File 'lib/heapscope/runtime/base.rb', line 66

def stop_allocation_tracing
  nil
end