{"id":256,"date":"2018-10-17T06:38:37","date_gmt":"2018-10-17T06:38:37","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/17\/what-is-dev-shm-in-linux\/"},"modified":"2018-10-17T06:38:37","modified_gmt":"2018-10-17T06:38:37","slug":"what-is-dev-shm-in-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/17\/what-is-dev-shm-in-linux\/","title":{"rendered":"What Is \/dev\/shm  in linux?"},"content":{"rendered":"<p><b><br \/><\/b> <\/p>\n<p>\nShared (Virtual) Memory (SHM)<\/p>\n<p><b><br \/><\/b> <\/p>\n<p>\nShared memory is a way to shared state between process.<\/p>\n<p>Shared memory, as its name implies, is a method to \u201cshare\u201d data between processes. <\/p>\n<p>\nBoth processes define the same memory area as \u201cshared\u201d, and they can then exchange <\/p>\n<p>\ninformation simply by writing into it. This (used to be, and still is somewhat) faster than <\/p>\n<p>\nthe alternative of sending network or pipe-based messages between processes.<\/p>\n<p>If you see the memory as a mean of storing data, a file on a file system can be seen as <\/p>\n<p>\nshared memory (ie shared file).<\/p>\n<p>It is difficult to account for shared memory. Does it belong to one process? Both? Neither?<\/p>\n<p>\n If we naively sum the memory belonging to multiple processes, we grossly \u201cover-count\u201d.<\/p>\n<p>As the name implies, the Shared (Virtual) Memory refers to virtual memory that are shared<\/p>\n<p>\n by more than one process and then can be used by multiple programs simultaneously.<\/p>\n<p>Although virtual memory allows processes to have separate (virtual) address spaces, there <\/p>\n<p>\nare times when you need processes to share memory.<\/p>\n<p>Shared memory (SHM) is another method of interprocess communication (IPC) <\/p>\n<p>\nwhereby several processes share a single chunk of memory to communicate.<\/p>\n<p>Shared memory provides the fastest way for processes to pass large amounts of data<\/p>\n<p>\n to one another.<\/p>\n<p><b><br \/><\/b> <\/p>\n<p>\n\/dev\/shm is nothing but implementation of traditional shared memory concept. It is an<\/p>\n<p>\n efficient means of passing data between programs. One program will create a memory <\/p>\n<p>\nportion, which other processes (if permitted) can access. This will result into speeding up <\/p>\n<p>\nthings on Linux.<\/p>\n<p><b><br \/><\/b> <\/p>\n<p>\nshm \/ shmfs is also known as tmpfs, which is a common name for a temporary file storage <\/p>\n<p>\nfacility on many Unix-like operating systems. It is intended to appear as a mounted <\/p>\n<p>\nfile system, but one which uses virtual memory instead of a persistent storage device.<\/p>\n<p>\nIf you type mount command you will see \/dev\/shm as a tempfs file system. Therefore, <\/p>\n<p>\nit is a file system, which keeps all files in virtual memory. Everything in tmpfs is temporary<\/p>\n<p>\n in the sense that no files will be created on your hard drive. If you unmount a tmpfs instance, everything stored therein is lost. By default almost all Linux distros configured to use \/dev\/shm.<\/p>\n<h3>\nDifference between tmpfs and swap<\/h3>\n<ul>\n<li>tmpfs uses memory while as swap uses persistent storage devices.<\/li>\n<li>tmpfs can be viewed as file system in df output whereas swap dont<\/li>\n<li>swap has general size recommendations, tmpsfs not. tmpfs size varies on system purpose.<\/li>\n<li>tmpfs makes applications fasters on loaded systems. swap helps system breath in memory full situations.<\/li>\n<li>swap full indicates system heavily loaded, degraded performance and may crash.<\/li>\n<li> tmpfs being full not necessarily means heavy load or prone to crash.<\/li>\n<li>tmpfs is enhancement where as swap is must have feature!<\/li>\n<\/ul>\n<ul><\/ul>\n<p><b><br \/><\/b> <br \/>\n<img loading=\"lazy\" decoding=\"async\" height=\"138\" src=\"https:\/\/lh6.googleusercontent.com\/ojgv6RWYaXVCTEGPsxWX0uNYYqLN82qge6Y4_N8Ee0Ca5aBygoTnx6UmyZwZJAfzYn1Esp44Pw7QGjtTfMaWmnvmnDz2gC1SG_tDUY-jDaWADZ7BoSbKU99iJH0STOMjQThZsuwU\" width=\"575\" \/><\/p>\n<p> <a href=\"https:\/\/www.linuxforfreshers.com\/2018\/10\/what-is-devshm-in-linux.html\" target=\"_blank\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Shared (Virtual) Memory (SHM) Shared memory is a way to shared state between process. Shared memory, as its name implies, is a method to \u201cshare\u201d data between processes. Both processes define the same memory area as \u201cshared\u201d, and they can then exchange information simply by writing into it. This (used to be, and still is &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/17\/what-is-dev-shm-in-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;What Is \/dev\/shm  in linux?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-256","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/256","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=256"}],"version-history":[{"count":0,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/256\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=256"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}