Display memory information
Syntax:
showmem [-D type] [-d file] [-P [pid]] [-S] [-v[v]...]
Options:
- -D type
- Show detailed process information.
The type is one or more of the following letters:
- h — heap
- l — libraries; the contribution from the shared objects
- m — memory mappings
- s — stack; the contribution from the threads
- -d file
- Dump the raw mapinfo into the specified file.
- -P [pid]
- Show a summary of the memory usage for the processes and the
shared libraries in the system.
If you specify pid, showmem displays information
only for the process with that ID.
- -S
- Show a summary of the free and used memory for the entire system.
- -v[v]...
- Increase the verbosity of the output.
You must specify at least one of these options.
Description:
The showmem utility displays memory information to help you
determine how your system is using memory.
-S option
If you specify the -S option, the output includes a summary for
the whole system.
For example:
System RAM: 511M ( 536394752)
Total Used: 381M ( 399794216)
Used Private: 378M ( 396812328)
Used Shared: 2912K ( 2981888)
The fields are as follows:
- System RAM: total RAM of the system
- Total used: the sum of the Used Private and Used Shared
- Used Private: private blocks, plus shared objects that are referenced
by only one process
- Used Shared: shared blocks that are referenced by more than one process
-P option
Use the -P option to display a summary of memory usage by the
processes and shared libraries in the system.
If you specify a pid, showmem displays the
memory information of the specified process;
if you don't, showmem displays the
memory summary of all processes and shared objects.
The report is broken down into these sections:
- Process
- The Process section shows the memory that the process claims it's consuming.
The fields are:
- Total: sum of Code + Data + Heap + Stack + Other
- Code: the code/text section of the process + the code/text section
of the shared libraries being used only by that process
- Data: the data/bss section of the process + the data/bss section of
the shared libraries referenced by that process
- Heap: the heap of the process
- Stack: the stack of the process
- Other: other memory not falling into the types above, mainly shared
memories referenced by the process
- process ID
- the name of the process
Let's take the process devc-con-hid as an example:
Process listing (Total, Code, Data, Heap, Stack, Other)
...
819200 602112 24576 167936 24576 0 4103 devc-con-hid
Total = 602112 + 24576 + 167936 + 24576 + 0 = 819200.
- Shared
- The Shared section shows all of the objects that have been identified
as being shared by more than one process mapping.
The fields are:
- Total: sum of Code + Data + Heap + Stack + Other
- Code: the code/text section of the shared library
- Data: 0
- Heap: 0
- Stack: 0
- Other: other memory not falling into the types above, mainly shared memory objects
- pid: -1
- name of the shared object
For example, libc.so.3 is referenced by almost all the
processes.
Therefore, it's shown in the Shared section; the information for it
could be like this:
Shared shared objects (Total, Code, Data, Heap, Stack, Other)
...
499712 499712 0 0 0 0 -1 proc/boot/libc.so.3
Here's another example of an entry for shared memory in the Shared section:
Shared shared objects (Total, Code, Data, Heap, Stack, Other)
...
4096 0 0 0 0 4096 -1 /dev/shmem/ctl-1002,5964,0
-D option
If you specify the -D option, showmem shows detailed
process information.
The Process section shows the breakdown of the code, data, stack, heap,
and libraries being used by the processes.
The Shared section is just the same as the Shared section shown with the
-P option.
Note:
If a value is shown in parentheses, this memory has already been accounted
for the total memory information.
This memory mapping might originate from within another, not allocated from
system RAM.
For example, if you specify -Dsl, the information for
devc-con-hid might look like this:
Process listing (Total, Code, Data, Heap, Stack, Other)
...
319488 102400 24576 167936 24576 0 4103 devc-con-hid
0 0 0 0 4096 0 4103 devc-con-hid (thread 2)
0 0 0 0 20480 0 4103 devc-con-hid (thread 1)
0 102400 8192 0 0 0 4103 devc-con-hid (proc/boot/devc-con-hid)
0 0 16384 0 0 0 4103 devc-con-hid (proc/boot/libc.so.3)
0 0 0 0 0 ( 36864) 4103 devc-con-hid (/dev/mem)
From the breakdown details, we can see:
- This process has two threads.
The stack size of thread 2 is 4096 bytes (4 KB), and the stack size of
thread 1 is 20480 bytes (20 KB).
- The private data of the shared library libc.so.3
contributes 16384 bytes to the total memory usage of the process.
- This process refers to the memory /dev/mem, but this
memory has already been accounted for in the total memory usage.
Therefore, we don't include this size in the total memory usage of
this process.