0
Hello I need to make a system call (in c/c++) that lists the memory consumption of processes anyone has any idea how I can do this ? i am using linux as s.o
0
Hello I need to make a system call (in c/c++) that lists the memory consumption of processes anyone has any idea how I can do this ? i am using linux as s.o
2
You can list all processes using command ps -eo pid, com (Returns the PID and process name) and query the memory information of each of them using /proc/$PID/statm (Returns the total memory of the process by the number of pages) or /proc/$PID/status in the Vmsize (Kb Memory) field. To read the information, simply use the file read functions to collect the data of your interest.
The ps command information is here: http://man7.org/linux/man-pages/man1/ps.1.html
All data information returned by proc-related commands here: http://man7.org/linux/man-pages/man5/proc.5.html
I see here for example the top command does something like this or I’m wrong ? but it seems to me that ps(works with processes) is what I’m really looking for.I also have to kill a process by implementing a program that uses the call to kill the processes that are consuming more memory than the value passed as parameter.Any idea?
Browser other questions tagged c
You are not signed in. Login or sign up in order to post.
would have to read the files in the /proc folder
– tomasantunes