1

I regularly use time to find out how long a process takes. Is there an equivalent command for memory? The usual ways to find out how much memory a process takes (ps,/proc/meminfo, etc.) work fine for a long-running process, but I don't know of anything that works like time does, for a command run from the command line. I'm imaging something like "size", except that includes the stack and heap:

% mem python myscript.py
   text    data    heap 
3135006  570928  115528
3
  • Yes indeed, it is. Thanks for the pointer! Commented May 3, 2016 at 3:46
  • You should be able to click the "Yes, this answered my question!" button to mark this one as a duplicate, then. Glad I could help. :)
    – Wildcard
    Commented May 3, 2016 at 4:07
  • I don't see where to do that. Commented May 4, 2016 at 14:38

1 Answer 1

0

Below stuff may help :

var=$(pgrep process_name_here);
top -b -p "$var" | awk -v var=$var '$1~var{print $10}'

You might even think of writing a script and passing the process name as argument

Note: This solution will not work if you change the default layout for the top command. In that case you need to replace $10 with appropriate field number

Not the answer you're looking for? Browse other questions tagged .