百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
G

get_process_mem

> 编程语言
开源

在 Ruby 中获取进程的内存使用情况

496 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

在 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 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

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