内存使用的“time”的等效命令?

内存使用的“time”的等效命令?

通过使用time我们可以轻松获取程序运行时间的信息。我想知道是否有任何等效的命令可以用于内存使用?比如为此进程分配了多少内存,完成后释放了多少内存?我知道我可以使用 Valgrind,但它对我来说有点太重了。

答案1

> /usr/bin/time -v sleep 1
Command being timed: "sleep 1"
User time (seconds): 0.00
System time (seconds): 0.00
Percent of CPU this job got: 0%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:01.01
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 1820
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 1
Minor (reclaiming a frame) page faults: 91
Voluntary context switches: 2
Involuntary context switches: 2
Swaps: 0
File system inputs: 16
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0

相关内容