Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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).

Reading the MAN page for top leads me to believe that the SHR column represents the amount of memory for interprocess communications via shared memory. Is this correct?

If so, then does it make sense for ANY process to have allocated 50 - 60 megabytes of shared memory (X11 only allocates 11MB, which seems reasonable based on what it has to do).

Thanks...

share|improve this question
    
What program specifically? –  John T Sep 28 '09 at 0:33
add comment

2 Answers

up vote 3 down vote accepted

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.
share|improve this answer
    
Thanks, this helps... –  user7029 Sep 28 '09 at 3:46
add comment

does it make sense for ANY process to have allocated 50 - 60 megabytes of shared memory

Yes.

For example, Oracle tuning guides have recommended shared memory sizes of gigabytes.

That said, if the process is "cat", it probably doesn't make much sense.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.