Class: Oink::Instrumentation::StatmMemorySnapshot

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)


67
68
69
# File 'lib/oink/instrumentation/memory_snapshot.rb', line 67

def self.available?
  File.exist?("/proc/self/statm")
end

.statm_page_sizeObject

try to get and cache memory page size. falls back to 4096.



52
53
54
55
56
57
58
59
60
61
# File 'lib/oink/instrumentation/memory_snapshot.rb', line 52

def self.statm_page_size
  @statm_page_size ||= begin
    sys_call = SystemCall.execute("getconf PAGESIZE")
    if sys_call.success?
      sys_call.stdout.strip.to_i / 1024
    else
      4
    end
  end
end

.unset_statm_page_sizeObject



63
64
65
# File 'lib/oink/instrumentation/memory_snapshot.rb', line 63

def self.unset_statm_page_size
  @statm_page_size = nil
end

Instance Method Details

#memoryObject



46
47
48
49
# File 'lib/oink/instrumentation/memory_snapshot.rb', line 46

def memory
  pages = File.read("/proc/self/statm")
  pages.to_i * self.class.statm_page_size
end