dmstat
Displays memory use information
MiniContents:
Arguments
Description
Examples
Format:
dmstat
Description:
The dmstat command displays information about how your program is using memory. After you enter this command, the CLI returns memory information. This information is displayed in three parts, as follows:
- memory usage summary: Indicates the minimum and maximum amounts of memory used by the text and data segments, the heap and the stack, as well as the virtual memory stack usage and the virtual memory size.
- Individual process statistics: Shows the amount of memory that each process is currently using.
- image information: Lists the name of the image, the image's text size, the image's data size, and the set of processes using the image.
The values shown in the six columns are:
text
The amount of memory used to store your program's machine code instructions. The "text segment" is sometimes called the "code segment."
data
The amount of memory used to store initialized data.
heap
The amount of memory currently being used for data created at runtime. The heap is an area of memory that your program uses when it needs to dynamically allocate memory. For example, calls to malloc() allocate space on the heap while free() releases it.
stack
The amount of memory used by the currently executing block or routines and all the blocks or routines that have invoked it. For example, if your main routine invokes function foo(), the stack contains two groups of information--these groups are called "frames." The first frame contains the information required for the execution of your main routine and the second, which is the current frame, contains the information needed by foo(). If foo() invokes bar(), the stack contains three frames. When foo() finishes executing, the stack only contains one frame.
stack_vm
The logical size of the stack is the difference between the current value of the stack pointer and address from which the stack originally grew. This value can differ from the size of the virtual memory mapping in which the stack resides. For example, the mapping can be larger than the logical size of the stack if the process previously had a deeper nesting of procedure calls or made memory allocations on the stack, or it can be smaller if the stack pointer has advanced but the intermediate memory has not been touched.
The value here is this size difference.
vm_size
The sum of the sizes of the mappings in the process's address space.
Examples:
dmstat
dmstat is sensitive to the focus, as this example from a four-process program shows:
process: text data heap stack [stack_vm] vm_size
1 (18549): 2257.08K 32.31M 17179869184.00G 9888 [ 278528] 22.70M
image information:
image_name text data dpids
....ry/forked_mem_exampleLINUX 5048 33556958 1
/lib/i686/libpthread.so.0 64344 55896 1
/lib/i686/libc.so.6 2101376 244676 1
/lib/ld-linux.so.2 140480 21626 1
dfocus a dmstat
The CLI prints the following on a four-process program:
process: text data heap stack [stack_vm] vm_size
1 (18549): 2257.08K 32.31M 17179869184.00G 9888 [ 278528] 22.70M
2 (18550): 2257.08K 32.31M 17179869183.99G 534192 [ 540672] 17.94M
3 (18551): 2257.08K 32.31M 17179869183.99G 796336 [ 802816] 18.19M
4 (18552): 2257.08K 32.31M 17179869183.99G 1033.67K [1040.00K] 18.44M
maximum:
1 (18549): 2257.08K 32.31M 17179869184.00G 9888 [ 278528] 22.70M
minimum
2 (18550): 2257.08K 32.31M 17179869183.99G 534192 [ 540672] 17.94M
image information:
image_name text data dpids
....ry/forked_mem_exampleLINUX 5048 33556958 1 2 3 4
/lib/i686/libpthread.so.0 64344 55896 1 2 3 4
/lib/i686/libc.so.6 2101376 244676 1 2 3 4
/lib/ld-linux.so.2 140480 21626 1 2 3 4