Method: LinuxStat::ProcessInfo.resident_memory

Defined in:
lib/linux_stat/process_info.rb

.resident_memory(pid = $$) ⇒ Object

resident_memory(pid = $$)

Where pid is the process ID.

By default it is the id of the current process ($$)

It retuns the resident memory for the process.

The value is in kilobytes.

The output is an Integer. For example:

LinuxStat::ProcessInfo.cpu_stat

=> 13996.032

If the info isn’t available it will return nil.



234
235
236
237
238
239
240
# File 'lib/linux_stat/process_info.rb', line 234

def resident_memory(pid = $$)
	file = "/proc/#{pid}/statm".freeze
	return nil unless File.readable?(file)

	_vm_rss = IO.read(file).split[1]
	_vm_rss ? _vm_rss.to_i.*(pagesize).fdiv(1000) : nil
end