使用Ruby从OSX获取我的进程的内存使用情况 [英] Getting memory usage of my process from OSX using Ruby

查看:95
本文介绍了使用Ruby从OSX获取我的进程的内存使用情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Ruby应用程序(在Linux上)使用/proc文件系统来获取有关其内存使用情况的信息.有谁知道如何获得Mac OSX的相同信息? task_info系统调用看起来很有希望,但是Ruby是否有等效的方法?

I have a Ruby app which (on Linux) uses the /proc filesystem to get information on its memory usage. Does anyone know how to get the same information for Mac OSX? The task_info system call looks promising but is there an equivalent available from Ruby?

要清楚,我正在寻找系统调用,我不想为此启动程序(对不起,拉尔斯!).

To be clear, I'm looking for a system call, I don't want to kick off a process for this (sorry Lars!).

推荐答案

请参阅此答案,看来您需要致电proc_pidinfo().我认为没有Ruby等效产品,因此您要么必须编写C扩展名,要么使用ruby-ffi gem.

Referring to this answer it seems like you need to call proc_pidinfo(). I don't think there's a Ruby equivalent, so either you'll have to write a C-extension or use the ruby-ffi gem.

其他来源表示Ruby 1.9.2带有内置的FFI-但该版本未随OS X一起提供.

Other sources indicate Ruby 1.9.2 ships with a built in FFI -- but that version is not delivered with OS X.

这篇关于使用Ruby从OSX获取我的进程的内存使用情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆