Linux memory: Difference between revisions

From DWIKI
Line 93: Line 93:
===Tools===
===Tools===
*[https://github.com/brendangregg/perf-tools perf-tools]
*[https://github.com/brendangregg/perf-tools perf-tools]
*https://www.brendangregg.com/blog/2014-12-31/linux-page-cache-hit-ratio.html


== Clear buffer/cache ==
== Clear buffer/cache ==


  sync; echo 3 > /proc/sys/vm/drop_caches
  sync; echo 3 > /proc/sys/vm/drop_caches

Revision as of 10:33, 10 November 2023


Links

Documentation

man 5 proc

see /proc/meminfo

total

Is MemTotal in /proc/meminfo

Total usable ram (i.e. physical ram minus a few reserved bits and the kernel binary code)

used

total - free - buffers - cache

unused

MemFree

RSS

Resident Set Size

RSS and VSZ in Linux memory management

"memory is allocated to that process and is in RAM. It does not include memory that is swapped out. It does include memory from shared libraries as long as the pages from those libraries are actually in memory. It does include all stack and heap memory."

VSZ / VmSize

Virtual Memory Size It includes all memory that the process can access, including memory that is swapped out, memory that is allocated, but not used, and memory that is from shared libraries.


ZFS and arc

Tools

  • arc_summary

Links


Changing arc sizes in runtime

#in bytes
echo 1024 > /sys/module/zfs/parameters/zfs_arc_min
echo 2048 > /sys/module/zfs/parameters/zfs_arc_max

Changing arc settings

In /etc/modprobe.d/zfs.conf:

options zfs zfs_arc_max=4294967296
options zfs zfs_arc_min=1073741824


If root on ZFS (really?)

update-initramfs -u -k all

FAQ

What is using all my memory?

smem -r -s swap| head -n3


What is using all my swap?

https://www.cyberciti.biz/faq/linux-which-process-is-using-swap/

for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 2 -n -r | less

or to just list top 3

for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 2 -n -r | head -n 3


What is in buffer/cache?

Tools

Clear buffer/cache

sync; echo 3 > /proc/sys/vm/drop_caches