UNIX Memory
Memory/Swap Information
free
free -m
free -mt
free -gt
Show figures in KB
Show figures in MB
Show figures in MB with Totals
Show figures in GB with Totals
See the awk script below for a reproduction of the internal available memory calculation (adapted from Stephen Kitt via unix.stackexchange)... zi=/proc/zoneinfomi=/proc/meminfoawk -v low=$(grep low ${zi}|awk '{k+=$2}END{print k}') \ '{a[$1]=$2} END{ print a["MemFree:"]+a["Active(file):"]+a["Inactive(file):"]+a["SReclaimable:"]-(12*low); }' ${mi}
awk '{a[$1]=$2} END{ print a["MemAvailable:"]/a["MemTotal:"]*100; }' /proc/meminfo
prtconf -m
svmon -G
work pers clnt otherpin 439364 0 3656 81136in use 601823 0 1059865
PageSize PoolSize inuse pgsp pin virtuals 4 KB - 1216136 3796 134348 156271m 64 KB - 27847 0 24363 27847L 16 MB - 0 0 0 0S 16 GB - 0 0 0 0
vmstat
vmstat 5 5
vmstat -a
vmstat -Itw 5 5
5 iterations, 5 seconds apart
Show inactive and active memory (instead of buff and cache)
(AIX) I/O oriented view ,with timestamp, wide mode
kthr memory page faults cpu time----------- --------------------- ------------------------------------ ------------------- ----------------------- -------- r b p avm fre fi fo pi po fr sr in sy cs us sy id wa pc ec hr mi se 27 13 0 8138927 5875 69120 10313 0 0 78175 155309 15391 56136 118802 45 47 3 5 3.90 195.0 13:12:35 32 11 0 8128587 5929 62101 5547 0 0 63686 159470 14366 184458 105148 47 46 3 4 3.90 194.8 13:12:40 30 7 0 8110765 5545 48682 2918 0 0 45613 105090 13471 330653 93227 54 36 5 5 3.88 193.9 13:12:45 18 7 0 8107437 6394 52499 3051 0 0 52707 109837 14381 391281 99667 55 35 5 5 3.93 196.4 13:12:50 43 14 0 8106457 5310 92296 2260 0 0 92307 207717 12866 367300 91384 48 42 4 6 3.92 196.1 13:12:55
- lcpu - logical processors
- mem - amount of memory
- ent - entitled capacity
Note: Entitled capacity relates to AIX LPAR functionality
- r - average runnable threads over the sampling interval
- b - average kernel threads placed in VMM wait queue (awaiting resourcem awaiting I/O) over the sampling interval
- p - average threads waiting for I/O messages from raw devices
- avm - active virtual pages shown as 4K chunks. Divide by 256 to convert to MB.
- fre - size of the free list.
- fi - file page-ins per second
- fo - file page-outs per second
- pi - number of pages paged in from paging space over the sampling interval
- po - number of pages paged out to paging space over the sampling interval
- fr - pages freed (page replacement)
- sr - pages scanned by page-replacement algorithm
- in - device interrupts
- sy - system calls
- cs - kernel thread context switches
- us - % user time
- sy - system time
- id - idle time
- wa - wait time (idle time during which the system had outstanding disk/NFS I/O requests)
- pc - processors consumed
- ec - entitled capacity
More information...
cat /proc/meminfo
dmidecode --type 17
lshw -short -C memory
Pagesize...
getconf PAGESIZE
Memory Nodes/Zones/Fragmentation...
cat /proc/buddyinfo
Information about storage used for swap...
cat /proc/swaps
cat /etc/fstab
Processes by Memory Usage
dstat -d --top-mem
Processes by % Memory Usage...
for file in /proc/*/status
do
awk '/VmSize|Name|Uid/{printf $2 " " $3}END{ print ""}' $file
done | grep 101 | awk '{sum+=$3;} END{print sum;}'
For a breakdown of memory usage for a specifc process (e.g. 222)...
pmap 222
For a breakdown of shared memory usage...
ipcs -b
Processes by % Memory Usage...
ps -o pid,user,%mem,command ax | sort -b -k3 -r
ps -eo pid,cmd,%mem,%cpu --sort=-%mem
ps -eo pid,euser,cmd,vsz --sort=-vsz
ps -eo pid,euser,comm,vsz --sort=-vsz | grep grid | awk '{sum+=$4;} END{print sum;}'
RSS = Resident Set Size -indicates used memory. But shared libraries are counted for each process.
Using top...
top
See the MEM% columnUsing htop...
htop
See the MEM% columnhtop
Top 15 Memory Hogs
svmon -Pt15 | perl -e 'while(<>){print if($.==2||$&&&!$s++);$.=0 if(/^-+$/)}'
ps aux | sort -n -k 6
ps alxww | sort -n -k 11
topas
Bibliography
https://linuxize.com/post/free-command-in-linux/ https://linuxhint.com/check_memory_usage_process_linux/ https://unix.stackexchange.com/questions/99334/how-to-fill-90-of-the-free-memoryhttps://stackoverflow.com/questions/1971422/linux-how-to-put-a-load-on-system-memoryhttps://blogs.oracle.com/linux/anticipating-your-memory-needshttps://www.fosslinux.com/43296/linux-ps-command-with-examples.htmhttps://man7.org/linux/man-pages/man1/ps.1.htmlhttps://www.kernel.org/doc/html/latest/filesystems/proc.htmlhttps://linuxconfig.org/ps-output-difference-between-vsz-vs-rss-memory-usagehttps://linuxconfig.org/how-to-monitor-ram-usage-on-linuxhttps://phoenixnap.com/kb/vmstat-commandhttps://www.linuxatemyram.com/https://unix.stackexchange.com/questions/478443/how-shall-i-understand-the-output-of-freehttps://unix.stackexchange.com/questions/261247/how-can-i-get-the-amount-of-available-memory-portably-across-distributionshttps://unix.stackexchange.com/questions/586249/swap-grows-slowly-with-80-available-memoryhttps://www.ibm.com/support/pages/memory-analysis-aix
https://tecadmin.net/add-swap-partition-on-ec2-linux-instance/
TODO:smemslabtophttps://unix.stackexchange.com/questions/361408/calculate-lpar-cpu-utilization-aix
https://support.oracle.comVirtual Memory Paging Reported Incorrectly on 11.2.0.3 (Doc ID 1515849.1)
AIX Memory Leakshttps://www.ibm.com/support/pages/memory-leak-diagnosis-aix