Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

The time command includes a format parameter "M", which according to the time man page on Linux is used for the following:

Maximum resident set size of the process during its lifetime, in Kilobytes.

However, it does not look like time is able to measure the maximum virtual set size of a process during its lifetime. How can I achieve this on Linux?

Just to be clear, I have control over the processes being profiled, so if I need to make this child process emit a signal at the end of its execution that indicates it is ready to terminate, so that the parent process can read its VSZ via ps or pmap, and then have the parent process explicitly terminate the child after the memory has been read, I can do it, but it would be painful, so I was hoping there might be a simpler solution that did not involve instrumenting the code of the program being profiled - something like a drop-in equivalent for time that can also measure maximum virtual set size would be ideal. I can write a custom C program to launch the child process, though, if need be. However, if I were to go the C route, I'm not sure what system calls I would use to enable kernel tracing of VSZ in the child process.

Any guidance would be appreciated.

EDIT: This turns out to be nontrivial. Possible solutions here: http://stackoverflow.com/questions/774556/peak-memory-usage-of-a-linux-unix-process/10957355#10957355

share|improve this question

1 Answer 1

Dunno whether it would be useful to you, but pidstat -r 1 -p 1 samples /sbin/init like this:

10:53:38          PID  minflt/s  majflt/s     VSZ    RSS   %MEM  Command
10:53:39            1      0.00      0.00   13648   1108   0.01  init
10:53:40            1      0.00      0.00   13648   1108   0.01  init
10:53:41            1      0.00      0.00   13648   1108   0.01  init
10:53:42            1      0.00      0.00   13648   1108   0.01  init
10:53:43            1      0.00      0.00   13648   1108   0.01  init
10:53:44            1      0.00      0.00   13648   1108   0.01  init
share|improve this answer
    
Do you know if sysstat is in LSB? –  JodieC Jun 9 '12 at 4:59
    
@JodieC, no idea, sorry. But this info could be easily fetched from /proc/PID/… for sure (in case). –  poige Jun 9 '12 at 5:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.