class Minitest::ShellPs

Return the resident set size (RSS) in kB.

This is fairly foolproof, but probably not the most accurate measure possible since shelling out most likely affects memory usage and isn’t terribly efficient.

Other strategies could be implemented in the future, for instance see NewRelic’s samplers: github.com/newrelic/rpm/blob/release/lib/new_relic/agent/samplers/memory_sampler.rb

Public Class Methods

new(pid = Process::pid) click to toggle source
# File lib/minitest/hog.rb, line 78
def initialize(pid = Process::pid)
  @pid = pid
end

Public Instance Methods

call() click to toggle source

Based off of: zogovic.com/post/59091704817/memory-usage-monitor-in-ruby Example ps output: “ RSSn223124n”

# File lib/minitest/hog.rb, line 84
def call
  `ps -o rss -p #{@pid}`.split("\n").last.to_i
end