Module: Process

Defined in:
lib/wdd-ruby-ext/system.rb

Class Method Summary collapse

Class Method Details

.mem_sizeObject

Returns the current process’ resident memory size in KB. May not work on all OS’s. Tested on Mac OS X only.



4
5
6
7
8
9
# File 'lib/wdd-ruby-ext/system.rb', line 4

def self.mem_size
  pid = Process.pid
  mem = `ps -o rsz #{pid}`
  mem.gsub!("RSZ", "").strip!
  mem
end

.show_mem(position = "undefined") ⇒ Object

Prints the process’ current resident memory size with an optional position marker.



12
13
14
15
# File 'lib/wdd-ruby-ext/system.rb', line 12

def self.show_mem position = "undefined"
  mem = Process.mem_size
  printf( "Resident Memory Size: #{mem}K - #{position}\n" )
end