简体   繁体   English

如何确定程序使用的最大内存?

[英]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: 另外,您可以将topcmdwatch一起使用,例如:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 你如何获得程序使用的内存量? - How do you get how much memory a program uses? 如何估算使用递归Java的程序的时间和内存消耗 - How to estimate the time and memory consumption of a program that uses recursion Java 程序使用Linux中的最大内存 - Program using maximum memory in linux 如何(不)处理高内存使用? - How to (not) deal with high memory uses? 所需的指标-Windows Server 2012为.NET程序分配的最大内存 - metrics needed - maximum memory allocation by Windows-Server-2012 for a .NET-program 如何证明程序受内存限制? - How can I prove that a program is memory bound? 如何证明程序版本具有更高的内存效率? - How to prove that a version of a program is more memory efficient? 程序如何在不读取整个文件的情况下确定文件的大小? - How does a program determine the size of a file without reading it whole? Valgrind 抱怨使用 std::ios_base::sync_with_stdio( false ) 的程序可能存在 memory 问题,为什么? - Valgrind complaining for possible memory problems from a program which uses std::ios_base::sync_with_stdio( false ) why? 实体框架使用了大量内存 - Entity framework uses a lot of memory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM