Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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).
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.
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."
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.