> 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
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://toska.gitbook.io/sysadmin/linux/memory.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
