LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 07-19-2007, 08:02 AM   #1
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990

Rep: Reputation: 65
How to calculate the total RAM used by several processes


Each process can have "normal" memory, shared memory (which may or may not be shared!) and code/library files, all of which seem to be included in the %RSS column on top.

We are trying to graph a breakdown of the RAM used by process, each running as a different user.

Is there some way we can work out how much system RAM (not swap space) is being used by a given list of PIDs, or even for each user?

Currently we are running top and scraping the values in the %RSS column, but these seem to add up to more than the total RAM used (excluding buffers+cached). I suspect this is because of shared code and libraries, and other shared memory, being counted multiple times.

I know about /proc/#/statm and /proc/#/status but I can't work out how to link the values between different processes.


For an abstract example (I don't have much real data at the moment), consider that two processes, A and B, both use libbig.so (50Mb), and B and C both share a 1Mb shared memory segment, and each happens to have a working-memory+code footprint of 10Mb:

Total RAM used by A = 60Mb
Total RAM used by B = 61Mb
Total RAM used by C = 11Mb
Sum total RAM used by A, B and C together = 182Mb (not a useful value!)
Aggregate total RAM used by A, B and C together = 81Mb (since the .so are shared).

Can anyone point me at some reference for this?
 
Old 07-19-2007, 08:14 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 11,799

Rep: Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923
I doubt an old version of Suse like that will be at the correct kernel version, but search for "smaps".
On later 2.6 kernels it is /proc/<pid>/smaps
 
Old 07-19-2007, 09:05 AM   #3
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990

Original Poster
Rep: Reputation: 65
Oops; I should update that.

Actually, this is not for my home machine anyway. It will be running on Red Hat Enterprise Linux 5 under kernel 2.6.9-perp-SMP-HIGHMEM (64-bit processors, probably Xeons).

Thanks for pointing me at smaps. I don't suppose there's some way to get a snapshot of processes by memory segment, rather than relying on nothing having changed while we iterate over processes?

In case it's useful, I also found this article (looking for documentation on smaps), which looks to be concerned with the same problem: http://bmaurer.blogspot.com/2006/03/...ith-smaps.html
 
Old 07-19-2007, 05:33 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 11,799

Rep: Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923
Short answer - no.

You might be able to get away with a kernel hack, but to make sure nothing changed, you'd be playing with a lot of locks you shouldn't be.
Samples are just that - no good trying to be too specific.

And yes that perl is handy - worth a look if you have an applicable kernel.

Last edited by syg00; 07-19-2007 at 05:34 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
small ram and too many processes gabsik Linux - Software 8 01-15-2007 09:50 AM
256 ram shows as 183284 total ram phreakshew Linux - Hardware 6 08-21-2006 02:37 PM
I don't understand how to calculate the total value of (ls -l) greeting Linux - General 7 08-12-2006 05:28 AM
[SOLVED] Using Himem kernel, but RAM total seems short? Eternal_Newbie Slackware 3 07-24-2005 03:35 PM
shared Memory versus the total amount of RAM on the server ashley75 Linux - General 1 08-25-2003 11:21 AM


All times are GMT -5. The time now is 10:55 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration