Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to compare memory usage between my program and sample program which is given by using ps in linux

mine and sample is written by c++ and I am not sure how to compare how much memory those two programs use by using ps in linux Thank you very much

share|improve this question

migrated from Oct 21 '11 at 19:13

This question came from our site for professional and enthusiast programmers.

I would start with man ps to find out what kind of information you can get from ps. – Greg Hewgill Oct 19 '11 at 21:46

You can see how much memory is using every process in Linux by using this command

top | grep <name>

Generally, if you want to list statistics about all the ongoing processes, you can use the 'top' command without making a pipeline.


... which outputs something similar to this:

1050 root      20   0  350m 125m  89m R   82  6.3   4288:11 Xorg                                                                                            
4633 kocko     20   0  972m 309m  28m R   28 15.4   1677:33 amarok                                                                                          
30624 kocko     20   0 1044m 225m  28m S   12 11.2   3:03.23 eclipse                                                                                         
31356 kocko     20   0  434m  60m  22m S    2  3.0 603:29.59 chrome                                                                                          
 1678 kocko     20   0 42972 7480 4764 S    2  0.4 146:14.10 compiz    
share|improve this answer

You should probably look into a profiling tool like Valgrind for your memory analysis. IIRC, the Linux memory manager will add new memory to your process when it needs it, but pages out unneeded memory rather than freeing it. So if you use tools like free and ps you will find memory leaks where there are none.

Update - it may be ps rather than the memory manager that is at "fault" here.

share|improve this answer

Your Answer


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