What is the meaning of `shared` memory in the `free` command?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
5
down vote

favorite
3












The fourth column in the output of free is named shared. On most outputs I can see in internet, the shared memory is zero. But that's not the case on my computer:



$ free -h
total used free shared buff/cache available
Mem: 7,7G 3,8G 1,1G 611M 2,8G 3,0G
Swap: 3,8G 0B 3,8G


Here is also an excerpt of the output of ps_mem.py:



 Private + Shared = RAM used Program
---------------------------------
21.4 MiB + 1.0 MiB = 22.4 MiB bash (9)
29.2 MiB + 5.3 MiB = 34.5 MiB Xorg
35.9 MiB + 858.5 KiB = 36.7 MiB tor
42.9 MiB + 9.6 MiB = 52.5 MiB urxvt (16)
121.0 MiB + 24.9 MiB = 145.8 MiB okular (2)
151.8 MiB + 2.8 MiB = 154.6 MiB soffice.bin
3.7 GiB + 209.3 MiB = 4.0 GiB chromium (39)
---------------------------------
4.6 GiB
=================================


What is the meaning of a shared memory?



Main answer in the Question 14102 says: shared: a concept that no longer exists. It's left in the output for backward compatibility. Looks insufficient to me. A "non-existent" concept does not take 600+ MB of RAM.










share|improve this question



















  • 4




    Possible duplicate of real memory usage
    – Tomasz
    Aug 31 '16 at 18:45










  • have you tried man free ?
    – Archemar
    Sep 1 '16 at 8:41










  • @Archemar manpage says: "shared: Memory used (mostly) by tmpfs (Shmem in /proc/meminfo)". That is not very clear; I'd like a more elaborate explanation.
    – BertS
    Sep 1 '16 at 15:06














up vote
5
down vote

favorite
3












The fourth column in the output of free is named shared. On most outputs I can see in internet, the shared memory is zero. But that's not the case on my computer:



$ free -h
total used free shared buff/cache available
Mem: 7,7G 3,8G 1,1G 611M 2,8G 3,0G
Swap: 3,8G 0B 3,8G


Here is also an excerpt of the output of ps_mem.py:



 Private + Shared = RAM used Program
---------------------------------
21.4 MiB + 1.0 MiB = 22.4 MiB bash (9)
29.2 MiB + 5.3 MiB = 34.5 MiB Xorg
35.9 MiB + 858.5 KiB = 36.7 MiB tor
42.9 MiB + 9.6 MiB = 52.5 MiB urxvt (16)
121.0 MiB + 24.9 MiB = 145.8 MiB okular (2)
151.8 MiB + 2.8 MiB = 154.6 MiB soffice.bin
3.7 GiB + 209.3 MiB = 4.0 GiB chromium (39)
---------------------------------
4.6 GiB
=================================


What is the meaning of a shared memory?



Main answer in the Question 14102 says: shared: a concept that no longer exists. It's left in the output for backward compatibility. Looks insufficient to me. A "non-existent" concept does not take 600+ MB of RAM.










share|improve this question



















  • 4




    Possible duplicate of real memory usage
    – Tomasz
    Aug 31 '16 at 18:45










  • have you tried man free ?
    – Archemar
    Sep 1 '16 at 8:41










  • @Archemar manpage says: "shared: Memory used (mostly) by tmpfs (Shmem in /proc/meminfo)". That is not very clear; I'd like a more elaborate explanation.
    – BertS
    Sep 1 '16 at 15:06












up vote
5
down vote

favorite
3









up vote
5
down vote

favorite
3






3





The fourth column in the output of free is named shared. On most outputs I can see in internet, the shared memory is zero. But that's not the case on my computer:



$ free -h
total used free shared buff/cache available
Mem: 7,7G 3,8G 1,1G 611M 2,8G 3,0G
Swap: 3,8G 0B 3,8G


Here is also an excerpt of the output of ps_mem.py:



 Private + Shared = RAM used Program
---------------------------------
21.4 MiB + 1.0 MiB = 22.4 MiB bash (9)
29.2 MiB + 5.3 MiB = 34.5 MiB Xorg
35.9 MiB + 858.5 KiB = 36.7 MiB tor
42.9 MiB + 9.6 MiB = 52.5 MiB urxvt (16)
121.0 MiB + 24.9 MiB = 145.8 MiB okular (2)
151.8 MiB + 2.8 MiB = 154.6 MiB soffice.bin
3.7 GiB + 209.3 MiB = 4.0 GiB chromium (39)
---------------------------------
4.6 GiB
=================================


What is the meaning of a shared memory?



Main answer in the Question 14102 says: shared: a concept that no longer exists. It's left in the output for backward compatibility. Looks insufficient to me. A "non-existent" concept does not take 600+ MB of RAM.










share|improve this question















The fourth column in the output of free is named shared. On most outputs I can see in internet, the shared memory is zero. But that's not the case on my computer:



$ free -h
total used free shared buff/cache available
Mem: 7,7G 3,8G 1,1G 611M 2,8G 3,0G
Swap: 3,8G 0B 3,8G


Here is also an excerpt of the output of ps_mem.py:



 Private + Shared = RAM used Program
---------------------------------
21.4 MiB + 1.0 MiB = 22.4 MiB bash (9)
29.2 MiB + 5.3 MiB = 34.5 MiB Xorg
35.9 MiB + 858.5 KiB = 36.7 MiB tor
42.9 MiB + 9.6 MiB = 52.5 MiB urxvt (16)
121.0 MiB + 24.9 MiB = 145.8 MiB okular (2)
151.8 MiB + 2.8 MiB = 154.6 MiB soffice.bin
3.7 GiB + 209.3 MiB = 4.0 GiB chromium (39)
---------------------------------
4.6 GiB
=================================


What is the meaning of a shared memory?



Main answer in the Question 14102 says: shared: a concept that no longer exists. It's left in the output for backward compatibility. Looks insufficient to me. A "non-existent" concept does not take 600+ MB of RAM.







linux memory ram






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 at 16:33









sourcejedi

21.9k43396




21.9k43396










asked Aug 31 '16 at 16:45









BertS

17118




17118







  • 4




    Possible duplicate of real memory usage
    – Tomasz
    Aug 31 '16 at 18:45










  • have you tried man free ?
    – Archemar
    Sep 1 '16 at 8:41










  • @Archemar manpage says: "shared: Memory used (mostly) by tmpfs (Shmem in /proc/meminfo)". That is not very clear; I'd like a more elaborate explanation.
    – BertS
    Sep 1 '16 at 15:06












  • 4




    Possible duplicate of real memory usage
    – Tomasz
    Aug 31 '16 at 18:45










  • have you tried man free ?
    – Archemar
    Sep 1 '16 at 8:41










  • @Archemar manpage says: "shared: Memory used (mostly) by tmpfs (Shmem in /proc/meminfo)". That is not very clear; I'd like a more elaborate explanation.
    – BertS
    Sep 1 '16 at 15:06







4




4




Possible duplicate of real memory usage
– Tomasz
Aug 31 '16 at 18:45




Possible duplicate of real memory usage
– Tomasz
Aug 31 '16 at 18:45












have you tried man free ?
– Archemar
Sep 1 '16 at 8:41




have you tried man free ?
– Archemar
Sep 1 '16 at 8:41












@Archemar manpage says: "shared: Memory used (mostly) by tmpfs (Shmem in /proc/meminfo)". That is not very clear; I'd like a more elaborate explanation.
– BertS
Sep 1 '16 at 15:06




@Archemar manpage says: "shared: Memory used (mostly) by tmpfs (Shmem in /proc/meminfo)". That is not very clear; I'd like a more elaborate explanation.
– BertS
Sep 1 '16 at 15:06










1 Answer
1






active

oldest

votes

















up vote
3
down vote













"Shared" in free and "Shmem" in /proc/meminfo count all the memory used by the tmpfs file system (a file system in the memory) and also the shared memory (allocated by shmget(2)).
This is documented in https://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt.



Here is an example from one of my servers:



$ free -k
total used free shared buff/cache available
Mem: 264036296 1275384 254696692 1182024 8064220 260536208
Swap: 63998972 0 63998972

$ grep Shmem /proc/meminfo
Shmem: 1182024 kB

$ df -BK | grep tmpfs
tmpfs 26403632K 51424K 26352208K 1% /run
tmpfs 132018148K 224K 132017924K 1% /dev/shm
tmpfs 5120K 4K 5116K 1% /run/lock
tmpfs 132018148K 0K 132018148K 0% /sys/fs/cgroup
tmpfs 251658240K 1129036K 250529204K 1% /run/shm
tmpfs 26403632K 24K 26403608K 1% /run/user/108
tmpfs 26403632K 0K 26403632K 0% /run/user/5800006


If you sum up the used size (3rd column) of all tmpfs filesystems listed by df, you will find the sum is equal to "shared" and "shmem".






share|improve this answer




















  • Thanks for explaining, but are those tmpfs are needed, Can I delete them and if possible how do I delete them?. I have encounter this issue many times after waking up the system from hibernation(~4GB is taken by shared)
    – Kasun Siyambalapitiya
    Oct 19 at 5:19











  • Hi @KasunSiyambalapitiya. Shmem also includes GEM graphics buffers, as per kernel source comments and lists.kernelnewbies.org/pipermail/kernelnewbies/2013-July/… . Some previous versions of systemd had a bug that leaked graphics buffers (seriously) when the graphics server exited... that was "fun". unix.stackexchange.com/questions/431982/… . That specific problem could only apply if your entire graphical session has been crashing, or if you have deliberately logged out of your whole session (and back in again).
    – sourcejedi
    Nov 19 at 16:44










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f307015%2fwhat-is-the-meaning-of-shared-memory-in-the-free-command%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
3
down vote













"Shared" in free and "Shmem" in /proc/meminfo count all the memory used by the tmpfs file system (a file system in the memory) and also the shared memory (allocated by shmget(2)).
This is documented in https://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt.



Here is an example from one of my servers:



$ free -k
total used free shared buff/cache available
Mem: 264036296 1275384 254696692 1182024 8064220 260536208
Swap: 63998972 0 63998972

$ grep Shmem /proc/meminfo
Shmem: 1182024 kB

$ df -BK | grep tmpfs
tmpfs 26403632K 51424K 26352208K 1% /run
tmpfs 132018148K 224K 132017924K 1% /dev/shm
tmpfs 5120K 4K 5116K 1% /run/lock
tmpfs 132018148K 0K 132018148K 0% /sys/fs/cgroup
tmpfs 251658240K 1129036K 250529204K 1% /run/shm
tmpfs 26403632K 24K 26403608K 1% /run/user/108
tmpfs 26403632K 0K 26403632K 0% /run/user/5800006


If you sum up the used size (3rd column) of all tmpfs filesystems listed by df, you will find the sum is equal to "shared" and "shmem".






share|improve this answer




















  • Thanks for explaining, but are those tmpfs are needed, Can I delete them and if possible how do I delete them?. I have encounter this issue many times after waking up the system from hibernation(~4GB is taken by shared)
    – Kasun Siyambalapitiya
    Oct 19 at 5:19











  • Hi @KasunSiyambalapitiya. Shmem also includes GEM graphics buffers, as per kernel source comments and lists.kernelnewbies.org/pipermail/kernelnewbies/2013-July/… . Some previous versions of systemd had a bug that leaked graphics buffers (seriously) when the graphics server exited... that was "fun". unix.stackexchange.com/questions/431982/… . That specific problem could only apply if your entire graphical session has been crashing, or if you have deliberately logged out of your whole session (and back in again).
    – sourcejedi
    Nov 19 at 16:44














up vote
3
down vote













"Shared" in free and "Shmem" in /proc/meminfo count all the memory used by the tmpfs file system (a file system in the memory) and also the shared memory (allocated by shmget(2)).
This is documented in https://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt.



Here is an example from one of my servers:



$ free -k
total used free shared buff/cache available
Mem: 264036296 1275384 254696692 1182024 8064220 260536208
Swap: 63998972 0 63998972

$ grep Shmem /proc/meminfo
Shmem: 1182024 kB

$ df -BK | grep tmpfs
tmpfs 26403632K 51424K 26352208K 1% /run
tmpfs 132018148K 224K 132017924K 1% /dev/shm
tmpfs 5120K 4K 5116K 1% /run/lock
tmpfs 132018148K 0K 132018148K 0% /sys/fs/cgroup
tmpfs 251658240K 1129036K 250529204K 1% /run/shm
tmpfs 26403632K 24K 26403608K 1% /run/user/108
tmpfs 26403632K 0K 26403632K 0% /run/user/5800006


If you sum up the used size (3rd column) of all tmpfs filesystems listed by df, you will find the sum is equal to "shared" and "shmem".






share|improve this answer




















  • Thanks for explaining, but are those tmpfs are needed, Can I delete them and if possible how do I delete them?. I have encounter this issue many times after waking up the system from hibernation(~4GB is taken by shared)
    – Kasun Siyambalapitiya
    Oct 19 at 5:19











  • Hi @KasunSiyambalapitiya. Shmem also includes GEM graphics buffers, as per kernel source comments and lists.kernelnewbies.org/pipermail/kernelnewbies/2013-July/… . Some previous versions of systemd had a bug that leaked graphics buffers (seriously) when the graphics server exited... that was "fun". unix.stackexchange.com/questions/431982/… . That specific problem could only apply if your entire graphical session has been crashing, or if you have deliberately logged out of your whole session (and back in again).
    – sourcejedi
    Nov 19 at 16:44












up vote
3
down vote










up vote
3
down vote









"Shared" in free and "Shmem" in /proc/meminfo count all the memory used by the tmpfs file system (a file system in the memory) and also the shared memory (allocated by shmget(2)).
This is documented in https://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt.



Here is an example from one of my servers:



$ free -k
total used free shared buff/cache available
Mem: 264036296 1275384 254696692 1182024 8064220 260536208
Swap: 63998972 0 63998972

$ grep Shmem /proc/meminfo
Shmem: 1182024 kB

$ df -BK | grep tmpfs
tmpfs 26403632K 51424K 26352208K 1% /run
tmpfs 132018148K 224K 132017924K 1% /dev/shm
tmpfs 5120K 4K 5116K 1% /run/lock
tmpfs 132018148K 0K 132018148K 0% /sys/fs/cgroup
tmpfs 251658240K 1129036K 250529204K 1% /run/shm
tmpfs 26403632K 24K 26403608K 1% /run/user/108
tmpfs 26403632K 0K 26403632K 0% /run/user/5800006


If you sum up the used size (3rd column) of all tmpfs filesystems listed by df, you will find the sum is equal to "shared" and "shmem".






share|improve this answer












"Shared" in free and "Shmem" in /proc/meminfo count all the memory used by the tmpfs file system (a file system in the memory) and also the shared memory (allocated by shmget(2)).
This is documented in https://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt.



Here is an example from one of my servers:



$ free -k
total used free shared buff/cache available
Mem: 264036296 1275384 254696692 1182024 8064220 260536208
Swap: 63998972 0 63998972

$ grep Shmem /proc/meminfo
Shmem: 1182024 kB

$ df -BK | grep tmpfs
tmpfs 26403632K 51424K 26352208K 1% /run
tmpfs 132018148K 224K 132017924K 1% /dev/shm
tmpfs 5120K 4K 5116K 1% /run/lock
tmpfs 132018148K 0K 132018148K 0% /sys/fs/cgroup
tmpfs 251658240K 1129036K 250529204K 1% /run/shm
tmpfs 26403632K 24K 26403608K 1% /run/user/108
tmpfs 26403632K 0K 26403632K 0% /run/user/5800006


If you sum up the used size (3rd column) of all tmpfs filesystems listed by df, you will find the sum is equal to "shared" and "shmem".







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 16 at 13:25









lqhl

313




313











  • Thanks for explaining, but are those tmpfs are needed, Can I delete them and if possible how do I delete them?. I have encounter this issue many times after waking up the system from hibernation(~4GB is taken by shared)
    – Kasun Siyambalapitiya
    Oct 19 at 5:19











  • Hi @KasunSiyambalapitiya. Shmem also includes GEM graphics buffers, as per kernel source comments and lists.kernelnewbies.org/pipermail/kernelnewbies/2013-July/… . Some previous versions of systemd had a bug that leaked graphics buffers (seriously) when the graphics server exited... that was "fun". unix.stackexchange.com/questions/431982/… . That specific problem could only apply if your entire graphical session has been crashing, or if you have deliberately logged out of your whole session (and back in again).
    – sourcejedi
    Nov 19 at 16:44
















  • Thanks for explaining, but are those tmpfs are needed, Can I delete them and if possible how do I delete them?. I have encounter this issue many times after waking up the system from hibernation(~4GB is taken by shared)
    – Kasun Siyambalapitiya
    Oct 19 at 5:19











  • Hi @KasunSiyambalapitiya. Shmem also includes GEM graphics buffers, as per kernel source comments and lists.kernelnewbies.org/pipermail/kernelnewbies/2013-July/… . Some previous versions of systemd had a bug that leaked graphics buffers (seriously) when the graphics server exited... that was "fun". unix.stackexchange.com/questions/431982/… . That specific problem could only apply if your entire graphical session has been crashing, or if you have deliberately logged out of your whole session (and back in again).
    – sourcejedi
    Nov 19 at 16:44















Thanks for explaining, but are those tmpfs are needed, Can I delete them and if possible how do I delete them?. I have encounter this issue many times after waking up the system from hibernation(~4GB is taken by shared)
– Kasun Siyambalapitiya
Oct 19 at 5:19





Thanks for explaining, but are those tmpfs are needed, Can I delete them and if possible how do I delete them?. I have encounter this issue many times after waking up the system from hibernation(~4GB is taken by shared)
– Kasun Siyambalapitiya
Oct 19 at 5:19













Hi @KasunSiyambalapitiya. Shmem also includes GEM graphics buffers, as per kernel source comments and lists.kernelnewbies.org/pipermail/kernelnewbies/2013-July/… . Some previous versions of systemd had a bug that leaked graphics buffers (seriously) when the graphics server exited... that was "fun". unix.stackexchange.com/questions/431982/… . That specific problem could only apply if your entire graphical session has been crashing, or if you have deliberately logged out of your whole session (and back in again).
– sourcejedi
Nov 19 at 16:44




Hi @KasunSiyambalapitiya. Shmem also includes GEM graphics buffers, as per kernel source comments and lists.kernelnewbies.org/pipermail/kernelnewbies/2013-July/… . Some previous versions of systemd had a bug that leaked graphics buffers (seriously) when the graphics server exited... that was "fun". unix.stackexchange.com/questions/431982/… . That specific problem could only apply if your entire graphical session has been crashing, or if you have deliberately logged out of your whole session (and back in again).
– sourcejedi
Nov 19 at 16:44

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f307015%2fwhat-is-the-meaning-of-shared-memory-in-the-free-command%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?