S
S
Seeker2021-02-26 12:08:57
linux
Seeker, 2021-02-26 12:08:57

How to understand what memory is spent on in linux?

There is a process that according to top consumes 13.5% of RAM. However, according to free, memory is used - 67.2%. How to understand where the rest of the memory went?

I tried to investigate the problem using tools such as /proc/meminfo, /proc/PID/status, free, top, smem.
What we have: I count the memory occupied by processes according to data from /proc/meminfo according to the formula MemTotal-Free-Cached-Buffers-Slab, it turns out the same value that shows free in the used line, somewhere 67.2% in relation to MemTotal , while this value increases with time, the memory "flows", but I can't figure out where exactly it flows: in some process or in the kernel.
If you examine the processes, then top shows me 3 columns: VIRT, RSS and SHR, the memory of each process consists of RSS and SHR, but since SHR is shared memory used by several processes simultaneously, these columns cannot be summarized. Then, instead of top, I used smem, which calculates such a value as PSS - proportional memory, which can already be summed up, smem also knows how to calculate the sum of all processes as a percentage, and so it showed me - 16.2%, while free says that 67.2% are employed, the question is where did the remaining 51% go?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
U
unseriously, 2021-02-26
@unseriously

do not thank:

ps axo rss,comm,pid | awk '{ proc_list[$2] += $1; } END { for (proc in proc_list) { printf("%d\t%s\n", proc_list[proc],proc); }}' | sort -n | tail -n 10 | sort -rn | awk '{$1/=1024;printf "%.0fMB\t",$1}{print $2}'

A
Andrew, 2021-02-26
@deepblack

https://www.linuxatemyram.com/

spoiler
6038c489d38b7941438363.png

V
Vitaly Karasik, 2021-02-26
@vitaly_il1

Show me, please
- free -m
- top -b -o +%MEM | head -n 25

D
Danil Tunev, 2021-02-26
@lada-guy

For me, htop is more convenient.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question