Module: Evilution::Memory Private
- Defined in:
- lib/evilution/memory.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: LeakCheck
Constant Summary collapse
- PROC_STATUS_PATH =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"/proc/%d/status"- RSS_PATTERN =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/VmRSS:\s+(\d+)\s+kB/
Class Method Summary collapse
- .delta ⇒ Object private
- .rss_kb ⇒ Object private
- .rss_kb_for(pid) ⇒ Object private
- .rss_mb ⇒ Object private
Class Method Details
.delta ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 34 35 36 37 |
# File 'lib/evilution/memory.rb', line 31 def delta before = rss_kb result = yield after = rss_kb delta_kb = before && after ? after - before : nil [result, delta_kb] end |
.rss_kb ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 |
# File 'lib/evilution/memory.rb', line 9 def rss_kb rss_kb_for(Process.pid) end |
.rss_kb_for(pid) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/evilution/memory.rb', line 20 def rss_kb_for(pid) path = format(PROC_STATUS_PATH, pid) content = File.read(path) match = content.match(RSS_PATTERN) return nil unless match match[1].to_i rescue Errno::ENOENT, Errno::EACCES, Errno::ESRCH nil end |
.rss_mb ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 16 17 18 |
# File 'lib/evilution/memory.rb', line 13 def rss_mb kb = rss_kb return nil unless kb kb / 1024.0 end |