Module: Appsignal::GarbageCollection Private

Defined in:
lib/appsignal/garbage_collection.rb

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

Defined Under Namespace

Classes: NilProfiler, Profiler

Class Method Summary collapse

Class Method Details

.clear_profiler!void

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.

This method returns an undefined value.

Unset the currently cached profilers.



33
34
35
36
# File 'lib/appsignal/garbage_collection.rb', line 33

def self.clear_profiler!
  @real_profiler = nil
  @nil_profiler = nil
end

.enabled?Boolean

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.

Check if Garbage Collection is enabled at the moment.

Returns:

  • (Boolean)


26
27
28
# File 'lib/appsignal/garbage_collection.rb', line 26

def self.enabled?
  GC::Profiler.enabled?
end

.profilerObject

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.

Return the GC profiler wrapper.

Returns Profiler if the Ruby Garbage Collection profiler is enabled. This is checked by calling GC::Profiler.enabled?.

GC profiling is disabled by default due to the overhead it causes. Do not enable this in production for long periods of time.



13
14
15
16
17
18
19
20
21
# File 'lib/appsignal/garbage_collection.rb', line 13

def self.profiler
  # Cached instances so it doesn't create a new object every time this
  # method is called. Especially necessary for the {Profiler} because a new
  # instance will have a new internal time counter.
  @real_profiler ||= Profiler.new
  @nil_profiler ||= NilProfiler.new

  enabled? ? @real_profiler : @nil_profiler
end