Home » Questions » Computers [ Ask a new question ]

Clarification on the Shared Memory column in the Linux top utility

Clarification on the Shared Memory column in the Linux top utility

We are having a memory allocation issues with a program running under Linux. We are using the top utility to try and determine the root cause of the problem. One thing that we have noticed is that one process has an excessively high value for shared memory (the SHR column in top).

Asked by: Guest | Views: 299
Total answers/comments: 1
Guest [Entry]

"The SHR column simply represents the amount of shared memory used by the process. It can be used for interprocess communications, but a more common scenario is that this is memory used by shared libraries that an application has linked in.

From The Linux Kernel: Memory Management:

Shared Virtual Memory

Although virtual memory allows processes to have separate (virtual)
address spaces, there are times when
you need processes to share memory.
For example there could be several
processes in the system running the
bash command shell. Rather than have
several copies of bash, one in each
processes virtual address space, it is
better to have only one copy in
physical memory and all of the
processes running bash share it.
Dynamic libraries are another common
example of executing code shared
between several processes.

Shared memory can also be used as an Inter Process Communication (IPC)
mechanism, with two or more processes
exchanging information via memory
common to all of them. Linux supports
the Unix TM System V shared memory
IPC.

What the top man page says about this column:

t: SHR -- Shared Mem size (kb)
The amount of shared memory used by a task. It simply reflects mem‐
ory that could be potentially shared with other processes."