Get current ruby process memory usage

The NewRelic gem provides simple RSS usage implementations for a number of operating systems and ruby runtimes with their MemorySampler class.

Include the newrelic_rpm gem in your Gemfile and invoke it thus:

NewRelic::Agent::Samplers::MemorySampler.new.sampler.get_sample

and it returns the number of megabytes of memory the current process holds as the RSS.

The implementation prefers in-process counters where available (jruby), use the /proc/#{$$}/status on Linux, and fall back to ps everywhere else.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)