0

Possible Duplicate:
Measuring RAM usage of a program

I am trying to use ps to benchmark a program, I'm just not sure which flags to use. I would like to get the amount of RAM the program used in total, what flag should I use?

Peppercat101
  • 189
  • 1
  • 1
  • 5
  • I assume you mean the total memory usage? That's already been answered: [Measuring RAM usage of a program](http://unix.stackexchange.com/q/18841) If you mean the current usage at the point when you run `ps`, see [Mathematical connection between SZ RSS and VSZ in ps o/p?](http://unix.stackexchange.com/q/32534) – Gilles 'SO- stop being evil' Sep 10 '12 at 00:00
  • I actually want to know the total RAM usage of just one of my processes... Im not that familiar with linux so Im not sure what I need, I tried the one answer ps axu|grep YOUR_PROCESS | grep -v grep|awk {'print $4'} and it printed 0.7... Im not sure 0.7 what exactly – Peppercat101 Sep 10 '12 at 08:23

2 Answers2

2
ps axu|grep YOUR_PROCESS | grep -v  grep|awk {'print $4'}
PersianGulf
  • 10,728
  • 8
  • 51
  • 78
  • This prints 0.7... What does the 0.7 mean? – Peppercat101 Sep 10 '12 at 08:24
  • tty which place of running process, if ? it means a kernel module , and if ttyN , such as tty3 ran in tty3, and ran in pts3 , ran in virtual tty, /dev/pts/N such as /dev/pts/3 are virtual tty sush as gnome-terminal. next field is STAT S,s,Zs+, for more info refer to man of ps.next field is Start that mentioned to start time of program.next field is TIME that mentioned to time of running program.last field is command , if enclosed in bracket it's a kernel module.Unfortunately i don't know about RSS and VSZ fields. – PersianGulf Sep 11 '12 at 00:47
2

For applications that run with more than one instance, you would need to sum the total. You could use awk to do this:

ps aux | awk '/YOUR_APP/ { sum+=$4 } END { print sum }'
jasonwryan
  • 71,734
  • 34
  • 193
  • 226