Ganesh S Ganesh S -5 years ago 110
Bash Question

How to Calculate Memory Used By A Command?

Consider I am running a command :

cprogram.c using gcc command

Memory used by following command:

gcc cprogram.c

Note :
top and ps commands are not supposed to be used.

I need other way to calculate memory used by command and this memory should be specific to this command only.

Answer Source

If you're on Linux, you can go straight to the source ps uses: information about memory usage (among other things) is exposed on the /proc filesystem. For example, try cat /proc/1234/status as root, where 1234 is the pid of the process.

Note that this would likely not count memory used by gcc's subprocesses.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download