[英]How to determine the maximum memory a program uses?
I am going to write a Perl program which is going to use accordingly preliminary benchmarks on small amounts of data about 100MB memory. 我将编写一个Perl程序,该程序将相应地对大约100MB内存的少量数据使用初步的基准测试。 I want to know the used amount of memory more precisely.
我想更准确地了解已使用的内存量。
How can I determine the amount of memory a Perl script uses? 如何确定Perl脚本使用的内存量?
There should be some command like (its name printmaxmemoryuse
is made up by me): 应该有一些类似的命令(它的名称
printmaxmemoryuse
由我组成):
printmaxmemoryuse perl myscript.pl
We are on FreeBSD. 我们在FreeBSD上。
In FreeBSD you can use procstat to get extend details about the process. 在FreeBSD中,您可以使用procstat来获取有关该过程的扩展详细信息。 for example to obtain the memory a process is consuming:
例如,获取进程正在消耗的内存:
procstat -r <PID>
Example output: 输出示例:
# 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
Also, you could use top
with cmdwatch for example: 另外,您可以将
top
与cmdwatch一起使用,例如:
cmdwatch -n1 'top -d 1 | grep 847'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.