I want to know which files from /proc directory and which fields of these files I need to calculate the memory usage of a given pid. I've been using the "stat" file and the "vsize" parameter that is in this file but it isn't a good calculation. Anyone knows a better formula for this? Thanks, Ana.
Indeed you need to use
/proc/; so read carefully proc(5).
For process 1234 you want to read
/proc/1234/smaps) to get the address space, and to read
For your own process (programmatically) use