RUVIDEO
Поделитесь видео 🙏

Unix & Linux: Correctly determining memory usage in Linux (7 Solutions!!)

Unix & Linux: Correctly determining memory usage in Linux


The Question: I'm a bit confused on some of the results I am seeing from ps and free.
On my server, this is the result of free -m
[root@server ~]# free -m
total used free shared buffers cached
Mem: 2048 2033 14 0 73 1398
-/+ buffers/cache: 561 1486
Swap: 2047 11 2036
My understanding of how Linux manages memory, is that it will store disk usage
in RAM, so that each subsequent access is quicker. I believe this is indicated
by the "cached" columns. Additionally, various buffers are stored in RAM,
indicated in the "buffers" column.
So if I understand correctly, the "actual" usage is supposed to be the "used"
value of "-/+ buffers/cache", or 561 in this case.
So assuming all of that is correct, the part that throws me is the results of
ps aux.
My understanding of the ps results, is that the 6th column (RSS), represents
the size in kilobytes the process uses for memory.
So when I run this command:
[root@server ~]# ps aux | awk '{sum+=$6} END {print sum / 1024}'
1475.52
Shouldn't the result be the "used" column of "-/+ buffers/cache" from free -m?
So, how can I properly determine the memory usage of a process in Linux?
Apparently my logic is flawed.

Solutions: Please watch the whole video to see all solutions, in order of how many people found them helpful

== This solution helped 10 people ==
Run top, hit h for help then f to add fields. you can add the following fields:
* RSS amount of physical memory the application is using
* CODE total amount of memory the process's executable code is using
* DATA - total amount of memory (kb) dedicated to a process's data and
stack
Between these 3 you should have pretty accurate results. You can also use more
detailed replacements for top I recommend htop or atop.
Edit: Almost forgot if you want really detailed information. Find the PID and
cat the following file.
PID=123
cat /proc/123/status
Edit 2: If you can find it or have it the book:
Optimizing Linux Performance: A Hands-On Guide to Linux Performance
Tools
-has a section Chapter 5: Performance Tools: Process-Specific Memory -it has
way more information than you would ever want.

== This solution helped 14 people ==
A really good tool is pmap which list the current usage of memory for a certain
process:
pmap -d PID
For more information about it see the man page man pmap and also have a look at
http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html, which list great
tools I always use to get information about my Linux box.

== This solution helped 5 people ==
ps gives you the amount of memory used by each process. Some of that memory is
mmapped files, which counts under cache. Some of that memory (especially code)
is shared with other processes, so if you add up the RSS values it's counted
multiple times.
There's no right answer to "how much memory does this process use?", because it
doesn't depend on the process alone, it also depends on the environment. There
are many different values you might call the "memory usage" of the process, and
they don't match or add up because they're counting different things.

With thanks & praise to God, and with thanks to the many people who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music: https://www.bensound.com/royalty-free-music | Images: https://stocksnap.io/license & others | With thanks to user Vineeth (https://unix.stackexchange.com/users/33508), user Patrizio Bertoni (https://unix.stackexchange.com/users/68245), user Patrick (https://unix.stackexchange.com/users/4358), user Miles F. Bintz II (https://unix.stackexchange.com/users/195138), user lemonsqueeze (https://unix.stackexchange.com/users/28431), user jasonwryan (https://unix.stackexchange.com/users/6761), user GoldenNewby (https://unix.stackexchange.com/users/16926), user Gilles 'SO- stop being evil' (https://unix.stackexchange.com/users/885), user ByteNudger (https://unix.stackexchange.com/users/15435), user 2bc (https://unix.stackexchange.com/users/13880), and the Stack Exchange Network (http://unix.stackexchange.com/questions/34795). Trademarks are property of their respective owners. Disclaimer: All information is provided "AS IS" without warranty of any kind. You are responsible for your own actions. Please contact me if anything is amiss at Roel D.OT VandePaar A.T gmail.com.

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Unix & Linux: Correctly determining memory usage in Linux (7 Solutions!!)», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.