Memory Usage Numbers In top/htop

Can someone please explain this top output. Each PHP process is using 30% of the total memory or of the used memory? Furthermore how can it be that the combined used memory across all the PHP processes far exceeds my system memory? Is this the shared memory?

Thanks in advance

top - 14:15:34 up 2 days, 12:38,  1 user,  load average: 0.97, 1.03, 0.93
Tasks: 124 total,   1 running, 123 sleeping,   0 stopped,   0 zombie
Cpu(s):  4.9%us,  0.3%sy,  0.0%ni, 94.6%id,  0.0%wa,  0.0%hi,  0.1%si,  0.1%st
Mem:   1029508k total,   992140k used,    37368k free,   150404k buffers
Swap:   262136k total,     2428k used,   259708k free,   551500k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 6695 www-data  20   0  548m 307m 292m S    0 30.6   8:06.55 php-fpm
 6697 www-data  20   0  547m 306m 292m S    0 30.4   7:59.64 php-fpm
 6691 www-data  20   0  547m 305m 291m S    2 30.4   8:04.96 php-fpm
 6689 www-data  20   0  547m 305m 291m S    2 30.3   8:07.55 php-fpm
 6696 www-data  20   0  540m 298m 292m S    1 29.7   8:13.43 php-fpm
 6705 www-data  20   0  540m 298m 292m S    0 29.7   8:17.24 php-fpm
 6699 www-data  20   0  540m 298m 291m S    4 29.7   8:07.39 php-fpm
 6701 www-data  20   0  541m 297m 289m S    0 29.6   7:59.87 php-fpm
 6700 www-data  20   0  540m 297m 290m S    0 29.5   8:09.92 php-fpm
 6694 www-data  20   0  541m 296m 288m S    2 29.5   8:05.18 php-fpm
 6707 www-data  20   0  541m 296m 288m S    0 29.5   8:09.40 php-fpm
 6692 www-data  20   0  541m 296m 289m S    0 29.5   8:14.23 php-fpm
 6706 www-data  20   0  541m 296m 289m S    3 29.5   8:07.59 php-fpm
 6698 www-data  20   0  541m 295m 288m S    4 29.4   8:04.85 php-fpm
 6704 www-data  20   0  539m 295m 289m S    2 29.4   8:13.58 php-fpm
 6708 www-data  20   0  540m 295m 288m S    1 29.4   8:14.27 php-fpm
 6802 www-data  20   0  540m 295m 288m S    3 29.3   8:11.63 php-fpm
 6690 www-data  20   0  541m 294m 287m S    3 29.3   8:14.54 php-fpm
 6693 www-data  20   0  539m 293m 287m S    2 29.2   8:16.33 php-fpm
 6702 www-data  20   0  540m 293m 286m S    0 29.2   8:12.41 php-fpm
 8641 www-data  20   0  540m 292m 285m S    4 29.1   6:45.87 php-fpm
 8640 www-data  20   0  539m 291m 285m S    2 29.0   6:47.01 php-fpm
 6703 www-data  20   0  539m 291m 285m S    2 29.0   8:17.77 php-fpm
 8642 www-data  20   0  540m 291m 284m S    0 29.0   6:42.98 php-fpm
 8646 www-data  20   0  540m 291m 284m S    0 28.9   6:41.18 php-fpm
10974 www-data  20   0  539m 285m 279m S    2 28.4   5:07.02 php-fpm
11827 www-data  20   0  539m 282m 275m S    0 28.1   4:28.41 php-fpm

Solution 1:

Yes, each php process is using 30% of the total memory.

An yes again, shared memory is why you cannot simply add. See the column "SHR", this is the shared memory value, RES stands for resident. From "man top" :

   n: %MEM  --  Memory usage (RES)
      A task's currently used share of available physical memory.


   o: VIRT  --  Virtual Image (kb)
      The total amount of virtual memory used by the task.  It includes all code, data and shared libraries plus pages that have been swapped out.

      VIRT = SWAP + RES.


   p: SWAP  --  Swapped size (kb)
      The swapped out portion of a task's total virtual memory image.


   q: RES  --  Resident size (kb)
      The non-swapped physical memory a task has used.

      RES = CODE + DATA.


   r: CODE  --  Code size (kb)
      The amount of physical memory devoted to executable code, also known as the 'text resident set' size or TRS.


   s: DATA  --  Data+Stack size (kb)
      The amount of physical memory devoted to other than executable code, also known as the 'data resident set' size or DRS.


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