如何确定程序使用的最大内存? [英] How to determine the maximum memory a program uses?

查看:67
本文介绍了如何确定程序使用的最大内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将编写一个Perl程序,该程序将相应地对大约100MB内存的少量数据使用初步的基准测试.我想更准确地了解已使用的内存量.

I am going to write a Perl program which is going to use accordingly preliminary benchmarks on small amounts of data about 100MB memory. I want to know the used amount of memory more precisely.

如何确定Perl脚本使用的内存量?

How can I determine the amount of memory a Perl script uses?

应该有一些命令,例如(它的名称 printmaxmemoryuse 由我组成):

There should be some command like (its name printmaxmemoryuse is made up by me):

printmaxmemoryuse perl myscript.pl

我们在FreeBSD上.

We are on FreeBSD.

推荐答案

FreeBSD 中,您可以使用 procstat 以获得有关该过程的扩展详细信息.例如获取进程正在消耗的内存:

In FreeBSD you can use procstat to get extend details about the process. for example to obtain the memory a process is consuming:

procstat -r <PID>

示例输出:

# procstat -r 847
PID COMM             RESOURCE                          VALUE
847 immortal         user time                    00:00:09.842315
847 immortal         system time                  00:00:26.680180
847 immortal         maximum RSS                             9884 KB
847 immortal         integral shared memory              11960644 KB
847 immortal         integral unshared data               1685608 KB
847 immortal         integral unshared stack               573824 KB
847 immortal         page reclaims                        1126497
847 immortal         page faults                              176
847 immortal         swaps                                      0
847 immortal         block reads                               57
847 immortal         block writes                          356464
847 immortal         messages sent                          13712
847 immortal         messages received                          2
847 immortal         signals received                       13708
847 immortal         voluntary context switches            272454
847 immortal         involuntary context switches           14765

此外,您可以将 top cmdwatch 一起使用例如:

Also, you could use top with cmdwatch for example:

cmdwatch -n1 'top -d 1 | grep 847'

这篇关于如何确定程序使用的最大内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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