LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 07-25-2009, 05:33 PM   #1
10110111
Member
 
Registered: Jun 2008
Location: St.-Petersburg, Russia
Distribution: (B)LFS, Ubuntu, SliTaz
Posts: 403

Rep: Reputation: 51
How to get size of memory used by each process?


I need to know, what process for what purpose is using memory in my machine. ps utility with various options seems to give not exactly what i want, i.e. if i sum all the values like RSS, VSZ or some other values related to memory usage, the sum is not equal (even approximately) to what i get using free|grep "buffers/cache".
How can i get this information? Even better, i would like to see contribution of every process, ramdisk, etc. to memory usage.
 
Old 07-27-2009, 02:02 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hi,

Using pmap will show you in detail what memory is used by a process, more it shows you what part of the program is using what and where (memory allocation).
Find out the PID number and execute
Code:
pmap pid
Hope this is what you're looking for.

Kind regards,

Eric
 
Old 07-27-2009, 08:41 AM   #3
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Despite a good understanding of the underlying principles of memory management, I've never managed to get a decent understanding of what things like SHR in top really mean.

I expect the inconsistencies or unexpected meaning of some of those statistics in top is the primary thing confusing the OP.

Looking at a process in top now I see
VIRT=419MB
RES=11MB
SHR=4.6MB

Looking at the same pid with pmap, I see almost entirely read only mapping, the largest of which is:
Code:
00002b3b6450e000  55084K r----  /usr/lib/locale/locale-archive
That same mapping occurs in other pids.

Since the total of SHR is 4.6MB and that mapping alone is 55MB, obviously that mapping and most of the similar read only file mappings are not SHR.

So is SHR just the resident portion of the shared mappings? That would seem to contradict such documentation as I've been able to find. Or are ordinary read only file mappings not shareable based on some other definition or rule?

Also pmap -x adds a column for RSS and for Anon but puts only '-' in that column. That pid does have resident memory (11MB) and does have anonymous memory (most of which is included in that same 11MB. What do RSS and Anon mean (not mentioned in the man page for pmap)? Is there any way to get decent info on such things (either better documentation on the meaning of the fields displayed by the obvious tools or better tools to display more meaningful stats)?

Also, from general principles of memory management, I know that significant portions of a process's virtual memory are either "demand zero" or "copy on write". To get any decent understanding of the overall memory use in a system you need to know how much is demand zero or copy on write. Some of the sysinternals tools for Windows identify much of the demand zero memory. But I don't know any tools in Linux to identify it or measure it or tell you anything about it.

I expect these are the same questions the OP wants to ask and I hope I'm helping by asking those questions with what I hope are helpful details. (Also I want to know more of this myself).

Last edited by johnsfine; 07-27-2009 at 08:50 AM.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
tool to detect number of memory slots, memory module type, speed, and size stefanwolf Linux - Hardware 8 04-22-2013 09:48 AM
Good Memory Size and Moemory Size in lsconf output Jaimine AIX 3 05-18-2009 01:07 PM
Get Process size and Thread count for a particular running process haseit Linux - Newbie 2 01-22-2009 11:09 PM
is shared memory expandable in memory size? Thinking Programming 4 08-16-2005 09:57 AM
Help Configuring the Memory Used by a Process in RedHat? (Cache Memory on CPU) geogecko Linux - General 3 02-23-2005 03:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:51 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration