Class: Instrumentation::Memory

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

Overview

Reads RSS memory from the PID specified

Instance Method Summary collapse

Constructor Details

#initialize(pid) ⇒ Memory

Returns a new instance of Memory.



4
5
6
# File 'lib/instrumentation/memory.rb', line 4

def initialize(pid)
  @pid = pid
end

Instance Method Details

#readObject



8
9
10
11
12
13
14
15
# File 'lib/instrumentation/memory.rb', line 8

def read
  case system
  when :mac_os
    rss_via_ps
  else
    raise "Unknown system #{system.inspect}"
  end
end

#rss_via_psObject



21
22
23
# File 'lib/instrumentation/memory.rb', line 21

def rss_via_ps
  `ps -o rss= -p #{@pid}`.strip.to_i
end

#systemObject



17
18
19
# File 'lib/instrumentation/memory.rb', line 17

def system
  :mac_os
end