LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-25-2015, 08:26 AM   #1
smunir362
LQ Newbie
 
Registered: Jan 2015
Posts: 10

Rep: Reputation: Disabled
ps command


I have a linux server.
I run ps -aex and see the rss field...
I calculate per process memory usage But it exceed from total ram of server.
I did not under stand it.
 
Old 01-25-2015, 08:41 AM   #2
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
What operating system is this on? When I run "ps -aex" on Debian there is no RAM data displayed.
 
Old 01-25-2015, 08:53 AM   #3
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
That is because much of the process memory is composed of shared libraries.

What you ended up doing is counting those shared libraries multiple times (once for each process), thus a shared library like libc (used by nearly every process) could get counted thousands of times, instead of the once that actually uses memory.

(and you likely did a "ps -lx" or "ps aux" command)

Last edited by jpollard; 01-25-2015 at 08:55 AM.
 
Old 01-26-2015, 02:14 AM   #4
smunir362
LQ Newbie
 
Registered: Jan 2015
Posts: 10

Original Poster
Rep: Reputation: Disabled
So what is the way to list and calculate actual ram used by each process in linux server.
 
Old 01-26-2015, 05:42 AM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Different question.

If you want to know how much ram a single process needs, include the shared libraries.

It is nearly useless to try to use that to aggregate all the processes. Guess what happens if you include a multi-threaded application - each thread uses the same code/libraries and the same data space... so the process sum would be the amount of memory used times the number of processes as each thread of the application is a process.

What is usually being asked is a different question: "Can I run <arbitrary application> on this system without running slow?"

Which can break down into "Will this force the system into heavy paging?"

That answer can be found by measurement - take the amount of free memory, minus the size of the program. This is the amount of memory needed for it to start. It doesn't include the amount of memory that may be needed as that depends on the size of the data... If it is a proprietary application the vendor SHOULD be able to help by supplying typical memory needs.

Actually run the program and see how much less free memory exists, measure the paging activity over several runs. If your swap gets used a good bit (and the application is running slow), then you likely need some more memory.

Usually, people just run the application and see what happens though.

Performance benchmarking is a bit of an art. If things don't run people usually would add swap space (its real cheap). If the program then runs, but slow, they can check the page fault rate and if they think it is high, they can add memory (it isn't quite as cheap as swap).
 
Old 01-26-2015, 06:08 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
and also an interesting question: should the ram occupied by shared libraries be taken into account? Do you know sometimes the process itself is not loaded into memory, just only a part of the binary code. And what about shared memory and swap?
 
Old 01-26-2015, 06:23 AM   #7
J Martin Rushton
Member
 
Registered: Jan 2015
Location: England
Distribution: Mainly CentOS
Posts: 31

Rep: Reputation: Disabled
rss = resident set size, that is the amount resident in memory and not paged out/unloaded. Have a look at the standard formats defined in the man page. Compare rss, vsz and sz (but keep clear of size).
 
  


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
Any Linux command output to delimited format. Script should work for any command. torrelm@hotmail.com Linux - Newbie 9 09-04-2014 08:54 AM
Command/Script required to send an email alert in case command will not respond rajaniyer123 Linux - General 1 05-19-2012 01:12 PM
Executing shell command from JSP file with command line arg from URL orcusomega Programming 2 01-13-2012 03:38 PM
Bash Command Line Editor, while typing run another command before executing current? gumaheru Linux - General 5 04-13-2010 11:21 AM
URGENT! Is there any command to get a history command lines and time in SUSE Linux.? igsoper Linux - Software 5 06-25-2009 02:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:21 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