Module: Gitlab::Memory::Jemalloc

Extended by:
Jemalloc
Included in:
Jemalloc
Defined in:
lib/gitlab/memory/jemalloc.rb

Constant Summary collapse

STATS_FORMATS =
{
  json: { options: 'J', extension: 'json' },
  text: { options: '', extension: 'txt' }
}.freeze
STATS_DEFAULT_FORMAT =
:json

Instance Method Summary collapse

Instance Method Details

#dump_stats(io, format: STATS_DEFAULT_FORMAT) ⇒ Object

Streams jemalloc stats to the given IO object.



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/gitlab/memory/jemalloc.rb', line 23

def dump_stats(io, format: STATS_DEFAULT_FORMAT)
  verify_format!(format)

  format_settings = STATS_FORMATS[format]

  with_malloc_stats_print do |stats_print|
    write_stats(stats_print, io, format_settings)
  end

  io
end

#stats(format: STATS_DEFAULT_FORMAT) ⇒ Object

Return jemalloc stats as a string.



18
19
20
# File 'lib/gitlab/memory/jemalloc.rb', line 18

def stats(format: STATS_DEFAULT_FORMAT)
  dump_stats(StringIO.new, format: format).string
end