Class: Instrumentation::Memory
- Inherits:
-
Object
- Object
- Instrumentation::Memory
- Defined in:
- lib/instrumentation/memory.rb
Overview
Reads RSS memory from the PID specified
Instance Method Summary collapse
-
#initialize(pid) ⇒ Memory
constructor
A new instance of Memory.
- #read ⇒ Object
- #rss_via_ps ⇒ Object
- #system ⇒ Object
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
#read ⇒ Object
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_ps ⇒ Object
21 22 23 |
# File 'lib/instrumentation/memory.rb', line 21 def rss_via_ps `ps -o rss= -p #{@pid}`.strip.to_i end |
#system ⇒ Object
17 18 19 |
# File 'lib/instrumentation/memory.rb', line 17 def system :mac_os end |