测量 Erlang 中操作系统进程(端口)内存使用情况
我有一个 Erlang 系统,可以在许多机器上运行用户指定的程序。 它使用 Erlang 端口来运行这些程序。 有时,程序会出现内存泄漏,并且可能会冻结生成它们的整个机器。
我如何测量 erlang 端口使用了多少内存?
不幸的是,erlang:memory/0 不包括端口内存。我应该使用 os:cmd/1 在内部调用 ps 然后解析其输出吗? 还是我在搜索时错过了更好的方法?
I have an Erlang system that runs user specified programs on many machines.
It uses Erlang ports to run those programs.
Sometimes programs have memory leaks and they can freeze entire machine that they were spawned on.
How can I measure, how much memory erlang port is using?
Unfortunately, erlang:memory/0 does not include port memory. Should I use os:cmd/1 invoking ps inside and then parse its output?
Or is there a better way that I missed while searching?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可以理解您希望在您的应用程序中处理此问题。但也许这样的问题最好通过设置
ulimit
或setrlimit
(假设您在 *nix 机器上运行)?如果您的操作系统有
/proc
文件系统,您可以在那里查找有关进程的信息。I can understand that you'd want to handle this from within your application. But maybe a problem like that would better be handled through setting
ulimit
orsetrlimit
(assuming you're running on a *nix-machine)?If your OS has a
/proc
-filesystem, you could look for info on your processes there.