Class: Skylight::VM::GC Private

Inherits:
Object show all
Defined in:
lib/skylight/vm/gc.rb,
lib/skylight/vm/gc.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

This doesn’t quite work as we would like it. I believe that the GC statistics includes time that is not stop-the-world, this does not necessarily take time away from the application.

require ‘java’ class GC

def initialize
  @factory = Java::JavaLangManagement::ManagementFactory
end

def enable
end

def total_time
  res = 0.0

  @factory.garbage_collector_mx_beans.each do |mx|
    res += (mx.collection_time.to_f / 1_000.0)
  end

  res
end

end

Instance Method Summary collapse

Constructor Details

#initializeGC

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of GC.



30
31
32
# File 'lib/skylight/vm/gc.rb', line 30

def initialize
  @total = 0
end

Instance Method Details

#enableObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



34
35
36
# File 'lib/skylight/vm/gc.rb', line 34

def enable
  ::GC::Profiler.enable
end

#total_timeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



38
39
40
41
42
43
44
45
# File 'lib/skylight/vm/gc.rb', line 38

def total_time
  # Reported in seconds
  run = (::GC::Profiler.total_time * 1_000_000).to_i

  ::GC::Profiler.clear if run > 0

  @total += run
end