LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-05-2012, 05:58 PM   #1
raindog308
Member
 
Registered: Dec 2010
Posts: 34

Rep: Reputation: 1
finding memory in use...using only ps


Long story short, I need to find out how much memory I have in use. Yeah, I know, free(1) is your friend. However, there's a bug with the particular virtualization I'm working with, and so inside the container, that isn't always reliable.

At the moment it is...and I ran ps aux, but adding up VSZ or RSS or VSZ-RSS isn't right.

So what do I want to look at in ps to find out how much memory each process is using so I can add those up?
 
Old 03-05-2012, 07:53 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,125

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Maybe just have a look at /proc/meminfo ?.
 
Old 03-05-2012, 08:51 PM   #3
raindog308
Member
 
Registered: Dec 2010
Posts: 34

Original Poster
Rep: Reputation: 1
free(1) just reads meminfo - it's really the same thing.
 
Old 03-06-2012, 08:06 AM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938
It is, frankly, extremely unlikely that there is "a bug in the virtualization you are working with." You are probably mis-reading the situation.

Aside from the fact that memory allocation changes from one microsecond to the next, much of the memory that you might be measuring is a shared resource, and the entire allocation and management scheme is "lazy." In other words, you might be counting the same bytes twice, and, if there is no actual, continuous pressure being applied to the memory manager, the system (by design...) is not making any efforts to economize.

Remember, the system has every incentive not to "clean up" something that, a few microseconds from now, someone might need to use again.
 
Old 03-06-2012, 10:42 AM   #5
raindog308
Member
 
Registered: Dec 2010
Posts: 34

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by sundialsvcs View Post
It is, frankly, extremely unlikely that there is "a bug in the virtualization you are working with." You are probably mis-reading the situation.
It's a bug with OpenVZ interacting with the .32 kernel on the host. To quote my provider:

"My apologies, this is a bug due in the .32 kernel the node is running. The only thing affected is how RAM is displayed, so it's not major enough to warrant a full node restart until we're ready for another round of upgrade."

Quote:
Aside from the fact that memory allocation changes from one microsecond to the next, much of the memory that you might be measuring is a shared resource, and the entire allocation and management scheme is "lazy." In other words, you might be counting the same bytes twice, and, if there is no actual, continuous pressure being applied to the memory manager, the system (by design...) is not making any efforts to economize.
I was hoping to get the same resolution as free(1).
 
Old 03-06-2012, 04:02 PM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,125

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Never going to happen I'd reckon.
See the "ps" manpage comments re size and RSS. Everything has page tables, even kernel threads - and if you happen to run something like Oracle, they can add up quickly.
Then there's things like slab. There's just too much you can't see, let alone how to count what you can see, like shared code. smaps tries to help, but you probably can't get the reference count to make a sensible total for the entire system.
 
1 members found this post helpful.
Old 03-06-2012, 04:44 PM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938
The bottom line when using commands like that is that you are in it, hurtling along the road along with everyone else who's on the same penguin-bus with you. You don't have an "outsider's" perspective, and you can never get one.

Each of the numbers produced by these various commands are intended only for comparative instantaneous inspection within their own current output ... and even then, "only approximately." They are not intended to "add up."
 
1 members found this post helpful.
Old 03-06-2012, 04:52 PM   #8
raindog308
Member
 
Registered: Dec 2010
Posts: 34

Original Poster
Rep: Reputation: 1
OK, thanks everyone for the replies.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding Memory Usage manoj.linux Linux - Enterprise 2 12-23-2011 11:28 AM
Finding linux actual memory usage wmasry Linux - General 1 12-16-2009 08:09 AM
Finding total free memory available for use by applications. Shashank Rachamalla Linux - General 1 08-17-2009 09:25 AM
Finding out the memory of my graphics card dvm Linux - Hardware 6 06-16-2009 04:37 PM
finding memory leak of a running process raees Linux - General 1 03-16-2004 10:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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