> For the complete documentation index, see [llms.txt](https://toska.gitbook.io/sysadmin/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://toska.gitbook.io/sysadmin/linux/memory.md).

# Memory

* free -mh
* vmstat&#x20;
* pdistat
* sar -r 2 2&#x20;
* pamp     #you need have pid
  * The pmap command reports the memory map of a process or processes.

```
 -x, --extended              show details
 -X                          show even more details
            WARNING: format changes according to /proc/PID/smaps
 -XX                         show everything the kernel provides
 -c, --read-rc               read the default rc
 -C, --read-rc-from=<file>   read the rc from file
 -n, --create-rc             create new default rc
 -N, --create-rc-to=<file>   create new rc to file
            NOTE: pid arguments are not allowed with -n, -N
 -d, --device                show the device format
 -q, --quiet                 do not display header and footer
 -p, --show-path             show path in the mapping
 -A, --range=<low>[,<high>]  limit results to the given range

 -h, --help     display this help and exit
 -V, --version  output version information and exit
```

#### pmap example

```
[root@sf-vm-1 perf-tools]# pmap -p -d 21601
21601:   nginx: master process /usr/sbin/nginx
Address           Kbytes Mode  Offset           Device    Mapping
00007f84fd8e1000      20 r-x-- 0000000000000000 0fd:00000 /usr/lib64/perl5/vendor_perl/auto/nginx/nginx.so
00007f84fd8e6000    2048 ----- 0000000000005000 0fd:00000 /usr/lib64/perl5/vendor_perl/auto/nginx/nginx.so
00007f84fdae6000       4 r---- 0000000000005000 0fd:00000 /usr/lib64/perl5/vendor_perl/auto/nginx/nginx.so
00007f84fdae7000       4 rw--- 0000000000000000 000:00000   [ anon ]
00007f84fdae8000     152 r-x-- 0000000000000000 0fd:00000 /usr/lib64/nginx/modules/ngx_stream_module.so
00007f84fdb0e000    2044 ----- 0000000000026000 0fd:00000 /usr/lib64/nginx/modules/ngx_stream_module.so
00007f84fdd0d000       4 r---- 0000000000025000 0fd:00000 /usr/lib64/nginx/modules/ngx_stream_module.so
00007f84fdd0e000      16 rw--- 0000000000026000 0fd:00000 /usr/lib64/nginx/modules/ngx_stream_module.so
00007f84fdd12000      88 r-x-- 0000000000000000 0fd:00000 /usr/lib64/nginx/modules/ngx_mail_module.so
00007f84fdd28000    2044 ----- 0000000000016000 0fd:00000 /usr/lib64/nginx/modules/ngx_mail_module.so
00007f84fdf27000       4 r---- 0000000000015000 0fd:00000 /usr/lib64/nginx/modules/ngx_mail_module.so
00007f84fdf28000       8 rw--- 0000000000016000 0fd:00000 /usr/lib64/nginx/modules/ngx_mail_module.so
00007f84fdf2a000      16 r-x-- 0000000000000000 0fd:00000 /usr/lib64/libgpg-error.so.0.10.0
00007f84fdf2e000    2044 ----- 0000000000004000 0fd:00000 /usr/lib64/libgpg-error.so.0.10.0
00007f84fe12d000       4 r---- 0000000000003000 0fd:00000 /usr/lib64/libgpg-error.so.0.10.0
00007f84fe12e000       4 rw--- 0000000000004000 0fd:00000 /usr/lib64/libgpg-error.so.0.10.0
00007f84fe12f000     500 r-x-- 0000000000000000 0fd:00000 /usr/lib64/libgcrypt.so.11.8.2
```

* dtrace

#### Clear cache/swap

```
To free pagecache:
    echo 1 > /proc/sys/vm/drop_caches
To free reclaimable slab objects (includes dentries and inodes):
    echo 2 > /proc/sys/vm/drop_caches
To free slab objects and pagecache:
    echo 3 > /proc/sys/vm/drop_caches
sync
```
