What is pmap linux

What is pmap linux

The pmap utility prints information about the address space of a process.

OPTIONS

The following options are supported:

-a Prints anonymous and swap reservations for shared mappings.

-A address_range Specifies the subrange of address space to display. address_range is specified in one of the following forms:

A single address limits the output to the segment (or the page if the -L option is present) containing that address. If the specified address corresponds to the starting address of a segment, the output always includes the whole segment even when the -L option is specified.

An address followed by comma without the end address limits the output to all segments (or pages if the -L option is present) starting from the one containing the specified address.

An address range specified by the start address and end addresses limits the output to all segments (or pages if the -L option is present) starting from the segment or page containing the start address through the segment or page containing the end address.

An address range started with comma without the start address limits the output to all segments (or pages if the -L option is present) starting from the first one present until the segment (or page if the -L option is present) containing the specified address.

-F Force. Grabs the target process even if another process has control.

-l Shows unresolved dynamic linker map names.

-L Prints lgroup containing physical memory that backs virtual memory.

-r Prints the process’s reserved addresses.

-s Prints HAT page size information.

-S Displays swap reservation information per mapping. See USAGE for more information.

-x Displays additional information per mapping. See USAGE for more information.

USAGE

The pmap utility prints information about the address space of a process.

By default, pmap displays all of the mappings in the virtual address order they are mapped into the process. The mapping size, flags, and mapped object name are shown.

The -A option can be used to limit the output to a specified address range. The specified addresses are rounded up or down to a segment boundary and the output includes the segments bounded by those addresses.

Process Lgroup Mappings

The -L option can be used to determine the lgroup containing the physical memory backing the specified virtual memory. When used with the -A option, the specified addresses are rounded up or down to a page boundary and the output is limited to the page or pages bounded by those addresses.

This can be used in conjunction with plgrp (1) to discover whether the home lgroup of a thread of interest is the same as where the memory is located and whether there should be memory locality for the thread. The lgrpinfo (1) command can also be useful with this pmap option. It displays the lgroup hierarchy, contents, and characteristics which gives more information about the lgroups that the memory is distributed across and their relationship to each other and any other lgroups of interest.

In addition, the thread and memory placement can be changed by using plgrp (1), pmadvise (1), or madv.so.1 (1).

Читайте также:  Office xml handler windows 10

Process anon/locked mapping details

The -x option displays additional information per mapping. The size of each mapping, the amount of resident physical memory (RSS), the amount of anonymous memory, and the amount of memory locked is shown with this option. This does not include anonymous memory taken by kernel address space due to this process.

The -S option displays swap reservation information per mapping.

Caution should be exercised when using the -F flag. Imposing two controlling processes on one victim process can lead to chaos. Safety is assured only if the primary controlling process, typically a debugger, has stopped the victim process and the primary controlling process is doing nothing at the moment of application of the proc tool in question.

DISPLAY FORMATS

One line of output is printed for each mapping within the process, unless the — -s or — -L option is specified. With -s option, one line is printed for a contiguous mapping of each hardware translation page size. With -L option one line is printed for a contiguous mapping belonging to the same lgroup. With both -L and -s options, one line is printed for a contiguous mapping of each hardware translation page size belonging to the same lgroup. The column headings are shown in parentheses below.

Virtual Address (Address )

The first column of output represents the starting virtual address of each mapping. Virtual addresses are displayed in ascending order.

Virtual Mapping Size (Kbytes )

The virtual size in kilobytes of each mapping.

Resident Physical Memory (RSS )

The amount of physical memory in kilobytes that is resident for each mapping, including that which is shared with other address spaces.

Anonymous Memory (Anon )

The number of pages, counted by using the system page size, of anonymous memory associated with the specified mapping. Anonymous memory shared with other address spaces is not included, unless the -a option is specified.

Anonymous memory is reported for the process heap, stack, for ‘copy on write’ pages with mappings mapped with MAP_PRIVATE (see mmap (2)).

The number of pages locked within the mapping. Typical examples are memory locked with mlock() and System V shared memory created with SHM_SHARE_MMU .

The virtual memory permissions are shown for each mapping. Valid permissions are:

r: The mapping can be read by the process.

w: The mapping can be written by the process.

x: Instructions that reside within the mapping can be executed by the process.

Flags showing additional information for each mapping can be displayed:

s: The mapping is shared such that changes made in the observed address space are committed to the mapped file, and are visible from all other processes sharing the mapping.

R: Swap space is not reserved for this mapping. Mappings created with MAP_NORESERVE and System V ISM shared memory mappings do not reserve swap space.

*: The data for the mapping is not present in the core file (only applicable when applied to a core file). See coreadm (1M) for information on configuring core file content.

The lgroup containing the physical memory that backs the specified mapping.

Mapping Name (Mapped File )

A descriptive name for each mapping. The following major types of names are displayed for mappings: o A mapped file: For mappings between a process and a file, the pmap command attempts to resolve the file name for each mapping. If the file name cannot be resolved, pmap displays the major and minor number of the device containing the file, and the file system inode number of the file. o Anonymous memory: Memory not relating to any named object or file within the file system is reported as [ anon ] .

Читайте также:  Kyocera fs 1020mfp сканер windows 10 как установить

The pmap command displays common names for certain known anonymous memory mappings:

[ heap ] The mapping is the process heap.

[ stack ] The mapping is the main stack.

[ stack tid= n ] The mapping is the stack for thread n .

[ altstack tid= n ] The mapping is used as the alternate signal stack for thread n .

If the common name for the mapping is unknown, pmap displays [ anon ] as the mapping name. o System V Shared Memory: Mappings created using System V shared memory system calls are reported with the names shown below:

shmid=n: The mapping is a System V shared memory mapping. The shared memory identifier that the mapping was created with is reported.

ism shmid=n: The mapping is an «Intimate Shared Memory» variant of System V shared memory. ISM mappings are created with the SHM_SHARE_MMU flag set, in accordance with shmat (2) (see shmop (2)).

dism shmid=n: The mapping is a pageable variant of ISM . Pageable ISM is created with the SHM_PAGEABLE flag set in accordance with shmat (2) (see shmop (2)).

o Other: Mappings of other objects, including devices such as frame buffers. No mapping name is shown for other mapped objects.

The page size in kilobytes that is used for hardware address translation for this mapping. See memcntl (2) for further information.

Swap Space (Swap )

The amount of swap space in kilobytes that is reserved for this mapping. That is, swap space that is deducted from the total available pool of reservable swap space that is displayed with the command swap -s . See swap (1M).

EXAMPLES

Example 1 Displaying Process Mappings

By default, pmap prints one line for each mapping within the address space of the target process. The following example displays the address space of a typical bourne shell:

Example 2 Displaying Memory Allocation and Mapping Types

The -x option can be used to provide information about the memory allocation and mapping types per mapping. The amount of resident, non-shared anonymous, and locked memory is shown for each mapping:

The amount of incremental memory used by each additional instance of a process can be estimated by using the resident and anonymous memory counts of each mapping.

In the above example, the bourne shell has a resident memory size of 1032Kbytes. However, a large amount of the physical memory used by the shell is shared with other instances of shell. Another identical instance of the shell shares physical memory with the other shell where possible, and allocate anonymous memory for any non-shared portion. In the above example, each additional bourne shell uses approximately 56Kbytes of additional physical memory.

A more complex example shows the output format for a process containing different mapping types. In this example, the mappings are as follows:

Example 3 Displaying Page Size Information

The -s option can be used to display the hardware translation page sizes for each portion of the address space. (See memcntl (2) for futher information on Solaris multiple page size support).

In the example below, we can see that the majority of the mappings are using an 8K-Byte page size, while the heap is using a 4M-Byte page size.

Notice that non-contiguous regions of resident pages of the same page size are reported as separate mappings. In the example below, the libc.so library is reported as separate mappings, since only some of the libc.so text is resident:

Example 4 Displaying Swap Reservations

The -S option can be used to describe the swap reservations for a process. The amount of swap space reserved is displayed for each mapping within the process. Swap reservations are reported as zero for shared mappings, since they are accounted for only once system wide.

Читайте также:  Значок mac os для windows

The swap reservation information can be used to estimate the amount of virtual swap used by each additional process. Each process consumes virtual swap from a global virtual swap pool. Global swap reservations are reported by the ‘ avail ‘ field of the swap (1M) command.

Example 5 Labeling Stacks in a Multi-threaded Process

Example 6 Displaying lgroup Memory Allocation

The following example displays lgroup memory allocation by mapping:

EXIT STATUS

The following exit values are returned:

0 Successful operation.

non-zero An error has occurred.

FILES

/proc/* process files

/usr/proc/lib/* proc tools supporting files

ATTRIBUTES

See attributes (5) for descriptions of the following attributes:

ATTRIBUTE TYPE ATTRIBUTE VALUE
Availability SUNWesu
Interface Stability

The command syntax is Evolving. The -L option and the output formats are Unstable.

Источник

Команда pmap в Linux с примерами

Команда pmap в Linux используется для отображения карты памяти процесса. Карта памяти показывает, как распределяется память.

Синтаксис:

Пример:

Параметры:

    -x: эта опция используется для отображения карты памяти в расширенном формате.

Пример:

-p: эта опция используется для отображения полного пути к файлам.

Пример:

-d: эта опция используется для отображения формата устройства.

Пример:

-q: эта опция используется для игнорирования имен столбцов при отображении отчета карты памяти.

Пример:

-A: эта опция используется для отображения результатов в заданном диапазоне. Обратите внимание, что аргументы low и high — это одна строка, разделенная запятой.

Пример:

-XX: эта опция используется для отображения всего, что предоставляет ядро.

Пример:

-n: эта опция используется для создания новой конфигурации.

Пример:

-c: эта опция используется для чтения конфигурации по умолчанию.

Пример:

  • -h: эта опция используется для отображения текста справки.
  • -v: эта опция используется для отображения информации о версии и выхода.
  • Источник

    How to Check Memory Usage of Process with Linux pmap Command

    The Linux pmap command displays the memory usage map of a process or multiple processes. Pmap reports information about the address space or memory usage map of a process.

    Pmap is actually a Sun OS command and Linux supports only very limited number of features. But it is very helpful for finding the complete address space of a process. To check memory usage of process we need PID or unique process ID of running process, we can get PID from /proc or regular commands like top or ps.

    Earlier we talked about process memory check using ps and top command, this tutorial I will teach how to use pmap command.

    Usage syntax

    Lets check the basic syntax of pmap command.

    In the output, it displays total address, kbytes, mode and mapping.

    Options

    1) Memory usage map of single process

    To check memory usage of a single process use map command followed by the PID number.

    Let’s check an pmap example:

    2) Memory usage map of multiple processes

    We can check memory map of multiple processes by inserting multiple PIDs. For that add multiple PIDs with adding space.

    3) Extended memory map about a process

    To print extended memory information of a process use -x option. Here Address, Kbyte, Dirty, RSS, mode and mapping contains information as below:

    Extended and Device Format Fields

    Conclusion

    In this tutorial we learn how to use pmap command to check memory information single and multiple processes. If you have any questions or feedback, feel free to leave a comment.

    Источник

    Оцените статью