Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to obtain information about memory used by different users and different processes which users are running and statistics about those processes like memory consumption ,execution speed etc using Linux system calls. I don't want to use commands like free,top etc.Can any one suggest how to do so?

share|improve this question
4  
The /proc filesystem is the typical source of this kind of information. –  Andy Apr 19 '11 at 3:52
add comment

1 Answer 1

It's important to understand how memory is used. A significant portion of memory is often shared. Any code used in a program and it's libraries are shared between different processes. Code is mapped into memory as read-only and is shared by all processes so it not owned by any one user. Certain libraries like libc are used by practically every single process, but are only loaded in RAM once. Programs that are more code heavily will have more shared memory than programs that are more data heavy.

To answer your question, nearly all the information that programs like top, free, and ps get comes from scanning the /proc filesystem. Every process has it's own folder named after it's PID. In there are a number of files like maps that show's it's memory map, comm that shows the command that was executed to start the process, and io that shows I/O usage. There's an introduction to /proc in the Linux Kernel Documentation.

share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.