Class: Oink::Instrumentation::SmapsMemorySnapshot

Inherits:
Object
  • Object
show all
Defined in:
lib/oink/instrumentation/memory_snapshot.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/oink/instrumentation/memory_snapshot.rb', line 81

def self.available?
  File.exist?("/proc/#{$$}/smaps")
end

Instance Method Details

#memoryObject



73
74
75
76
77
78
79
# File 'lib/oink/instrumentation/memory_snapshot.rb', line 73

def memory
  proc_file = File.new("/proc/#{$$}/smaps")
  lines = proc_file.lines
  lines.map do |line|
    size = line[/Size: *(\d+)/, 1] and size.to_i
  end.compact.sum
end