【问题标题】:How to determine the maximum memory a program uses?如何确定程序使用的最大内存?
【发布时间】:2018-02-23 20:21:44
【问题描述】:

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

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

应该有类似的命令(它的名字printmaxmemoryuse是我编的):

printmaxmemoryuse perl myscript.pl

我们在 FreeBSD 上。

【问题讨论】:

  • 可能类似于/usr/bin/time -l perl myscript.pl

标签: performance memory command freebsd measure


【解决方案1】:

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

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

另外,您可以将topcmdwatch 一起使用,例如:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-03
    • 1970-01-01
    • 2014-12-09
    • 2014-05-15
    • 2021-12-23
    • 1970-01-01
    • 2016-10-16
    相关资源
    最近更新 更多