Hi, Le Fri, 21 Sep 2007 17:55:48 +0530, "Rajath N R" <rajathnr@xxxxxxxxx> a écrit : > My task is like this : > customizing the PS sources inorder to get the memory usage of two > specific processes. > so, it's like ... when i run a C/C++ binary it should result in > giving the sum of the memory > used by the two known processes. I can get it by using PS itself with > options like "aux" and > "vsz" which result in giving memory used in KB....but i wanted to > know if there is any > system call() which gives me the same. You can have a look at /proc/<pid>/statm. It contains the virtual size of the process, the resident size, the size of the memory shared, the size of the text segment, 0, the size of the data, 0. All sizes are in pages. Example: $ ps aux | grep evince | grep -v grep 515 1945 0.0 3.7 78900 19324 ? Sl Sep19 0:34 evince foobar.pdf $ cat /proc/1945/statm 19725 4831 2877 176 0 5987 0 And 19725 * 4 is 78900 (virtual size), 4831 * 4 is 19324 (resident size). You can have a look at http://lxr.free-electrons.com/source/fs/proc/array.c#482 to see how it's implemented. In fact, most of the programs such as 'top' or 'ps' do not get their informations through system calls, but through the /proc filesystem. Sincerly, Thomas -- Thomas Petazzoni - thomas.petazzoni@xxxxxxxx http://{thomas,sos,kos}.enix.org - http://www.toulibre.org http://www.{livret,agenda}dulibre.org -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ