Module: Pgbus::Process::MemoryUsage
- Defined in:
- lib/pgbus/process/memory_usage.rb
Constant Summary collapse
- MEMORY_CHECK_TTL =
5
Class Method Summary collapse
Class Method Details
.current_mb ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/pgbus/process/memory_usage.rb', line 13 def current_mb @mutex.synchronize do now = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) return @cached_value if @cached_value && @cached_at && (now - @cached_at) < MEMORY_CHECK_TTL @cached_value = read_memory @cached_at = now @cached_value end end |
.reset! ⇒ Object
25 26 27 28 29 30 |
# File 'lib/pgbus/process/memory_usage.rb', line 25 def reset! @mutex.synchronize do @cached_value = nil @cached_at = nil end end |