Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
G

get_process_mem

> 编程语言
Open source

Get memory usage of a process in Ruby

496 stars0 likes1 views
WebsiteGitHub

About

Get memory usage of a process in Ruby

Get Process Memory

Do you need to get the memory usage of a process? Great because this library does that.

Install

In your Gemfile add

ruby
gem 'get_process_mem'

then run $ bundle install.

If you're using Windows you'll also need to have the sys-proctable gem.

Use It

Get the current process memory usage:

ruby
mem = GetProcessMem.new
puts mem.inspect
#
mem.bytes # => 25460736
mem.kb    # => 24864.0
mem.mb    # => 24.28125
mem.gb    # => 0.023712158203125

Note: All numeric values returned as a float except bytes which is an integer.

Get memory usage of another process:

ruby
`echo 'nothing to see here' > tmplogf`
pid = Process.spawn('tail -f tmplog')
mem = GetProcessMem.new(pid)
puts mem.inspect
# => #

Process.kill('TERM', pid)
Process.wait(pid)

mem.inspect
# => "#"
`rm tmplog`

On Linux, for memory size we return the RSS or the Resident Set Size, basically how much memory the program takes up in RAM at the time, including all the shared memory.

License

MIT

Issues· 5 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Ruby

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言