{"id":395416,"date":"2022-01-17T17:00:29","date_gmt":"2022-01-17T14:00:29","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/easily-understand-your-linux-ram-usage-with-smem\/"},"modified":"2022-01-17T17:00:29","modified_gmt":"2022-01-17T14:00:29","slug":"easily-understand-your-linux-ram-usage-with-smem","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/easily-understand-your-linux-ram-usage-with-smem\/","title":{"rendered":"#Easily Understand Your Linux RAM Usage With Smem"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2cfda9898b1\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2cfda9898b1\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/easily-understand-your-linux-ram-usage-with-smem\/#Memory_Usage\" >Memory Usage<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/easily-understand-your-linux-ram-usage-with-smem\/#The_RSS_the_USS_and_the_PSS\" >The RSS, the USS, and the PSS<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/easily-understand-your-linux-ram-usage-with-smem\/#The_smem_Utility\" >The smem Utility<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/easily-understand-your-linux-ram-usage-with-smem\/#Refining_the_Report\" >Refining the Report<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/easily-understand-your-linux-ram-usage-with-smem\/#Reporting_on_a_Single_Program\" >Reporting on a Single Program<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/buradabiliyorum.com\/en\/easily-understand-your-linux-ram-usage-with-smem\/#Generating_Graphs\" >Generating Graphs<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/buradabiliyorum.com\/en\/easily-understand-your-linux-ram-usage-with-smem\/#Good_Things_Come_In_Small_Packages\" >Good Things Come In Small Packages<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#Easily Understand Your Linux RAM Usage With Smem&#8221;<\/strong><\/p>\n<div>\n<figure style=\"width: 1200px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage size-full wp-image-771470 \" data-pagespeed-lazy-srcset=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/11\/hero-1.png?width=398&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 400w, https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/11\/hero-1.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 1200w\" sizes=\"auto, 400w, 1200w\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/11\/hero-1.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Laptop screen showing the Bash shell logo over a red backdrop\" width=\"1200\" height=\"675\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><figcaption class=\"wp-caption-text\"><span class=\"type:primaryImage imagecredit\"><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.shutterstock.com\/image-vector\/linux-interface-screen-notebook-world-map-321627716\">fatmawati achmad zaenuri\/Shutterstock<\/a><\/span><\/figcaption><\/figure>\n<p>Linux memory usage can be difficult to interpret and hard to understand. With <code>smem<\/code> it\u2019s easy to find out what memory a process is using, and which processes are using the most.<\/p>\n<h2 id=\"memory-usage\"><span class=\"ez-toc-section\" id=\"Memory_Usage\"><\/span>Memory Usage<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Linux gives you many ways to check what\u2019s h<a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a>ening with your computer\u2019s RAM. The problem is, memory management is a complicated challenge for your operating system. It has to juggle physical RAM, virtual RAM in the form of swap space, and the demands of the different types of processes that are running at any one time.<\/p>\n<p>Processes consume RAM as they load themselves into memory. They then request more RAM so that they have space to perform whatever tasks it is they\u2019re designed to do. Some processes hardly impact RAM, others are very memory-hungry.<\/p>\n<p>The kernel and the rest of the operating system, your desktop environment, and every application or command line session you run are all clamoring for a portion of the finite amount of RAM installed in your computer. Some processes spawn other processes. Some processes share RAM with other processes.<\/p>\n<p>Trying to decipher all of this and to come up with a simple answer to the question \u201cHow much RAM is this program or process using?\u201d can be a surprising challenge. Granularity is great and has its place but, equally, information overkill can be an impediment.<\/p>\n<p>For example, using\u00a0<code>cat<\/code> to peek into the\u00a0<a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/man7.org\/linux\/man-pages\/man5\/proc.5.html\">\/proc\/meminfo pseudo filesystem<\/a>\u00a0returned 50 lines of output on the machine used to research this article. Where do you start?<\/p>\n<pre>cat \/proc\/meminfo<\/pre>\n<p>And some Linux utilities give different answers. On our test machine, we had an instance of <code>less<\/code> running, which had a process ID of 2183.<\/p>\n<p>We can use the <code>pmap<\/code> utility with the <code>-x<\/code> (extended) option to get a full picture of the memory usage of a process. We\u2019ll use it with the process ID of our instance of <code>less<\/code>:<\/p>\n<pre>pmap -x 2183<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-773165\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/12\/4.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Querying the memory map of a single process\" width=\"644\" height=\"55\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>At the bottom of the output, we get a total for the Resident Set Size, which is the amount of main RAM being used.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-773176\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/12\/5-1.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"The pmap output for a single instance of less\" width=\"644\" height=\"380\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>We then used the <code>ps<\/code> utility with the <code>-o<\/code> (output) option, selected the <code>RSS<\/code> column, and passed it the process ID of the same instance of <code>less<\/code>:<\/p>\n<pre>ps -o rss 2183<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-773177\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/12\/6-1.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Using ps to see the RSS of the same instance of less\" width=\"644\" height=\"110\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>We get a different result. This is a design decision on the part of the <code>ps<\/code> authors. This is from the <code>ps<\/code> <code>man<\/code> page:<\/p>\n<p>The SIZE and RSS fields don\u2019t count some parts of a process including the page tables, kernel stack, struct thread_info, and struct task_struct. This is usually at least 20 KiB of memory that is always resident. SIZE is the virtual size of the process (code+data+stack).<\/p>\n<p>The authors of other utilities have their own views on how to measure RAM usage.<\/p>\n<h2 id=\"the-rss-the-uss-and-the-pss\"><span class=\"ez-toc-section\" id=\"The_RSS_the_USS_and_the_PSS\"><\/span>The RSS, the USS, and the PSS<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The Resident Set Size (RSS) is the amount of RAM allocated to a process, excluding swap space, but including any RAM required by shared libraries that the process is using.<\/p>\n<p>RSS almost always over-reports RAM usage. If two or more processes use one or more shared libraries, RSS will simply add the RAM usage of each library to its count of RAM usage for each of those processes. As well as inaccuracy, there\u2019s a certain irony to this. Shared libraries mean each process doesn\u2019t need to load its own private instance of a library. If the library is already in memory it\u2019ll share that one\u2014and reduce the RAM overhead.<\/p>\n<p>The Proportional Set Size tries to address this by dividing the amount of shared memory amongst the processes that are sharing it. If there are four processes sharing some memory, PSS reports that 25% of the shared RAM is used by each of those processes. This is an approximation but it more closely resembles what\u2019s going on than the picture that RSS paints.<\/p>\n<p>The Unique Set Size is the amount of RAM that is being used exclusively by a process whether it is directly consumed by the process, or used by libraries that are solely in use by the process. Again, it ignores swap space. It\u2019s only interested in genuine, physical RAM.<\/p>\n<p>USS and PSS are terms and concepts that were\u00a0<a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/elinux.org\/images\/6\/68\/Smem.pdf\">proposed by Matt Mackall<\/a>, the author of <code>smem<\/code>.<\/p>\n<h2 id=\"the-smem-utility\"><span class=\"ez-toc-section\" id=\"The_smem_Utility\"><\/span>The smem Utility<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The <code>smem<\/code> utility reports on memory used by processes, users, mapping, or system-wide. On all\u00a0distributions we tested, it required installing. To install it on Ubuntu, use this command:<\/p>\n<pre>sudo apt install smem<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-773182\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/12\/1.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Installing smem on Ubuntu\" width=\"644\" height=\"55\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>To install <code>smem<\/code> on Fedora you need to type:<\/p>\n<pre>sudo dnf install smem<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-773184\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/12\/2.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Installing smem on Fedora\" width=\"644\" height=\"55\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>To install <code>smem<\/code> on Manjaro use:<\/p>\n<pre>sudo pacman -Sy smem<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-773185\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/12\/3.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Installing smem on Manjaro\" width=\"644\" height=\"55\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Using <code>smem<\/code> with no options gives you a list of the processes that are using RAM.<\/p>\n<pre>smem<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-773186\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/12\/7.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Invoking smem with no command line options\" width=\"644\" height=\"55\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>A table of information is displayed in the terminal window.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-773188\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/12\/8.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"The default output of smem\" width=\"644\" height=\"336\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The columns are:<\/p>\n<ul>\n<li><strong>PID<\/strong>: The process ID of the process that\u2019s using the memory.<\/li>\n<li><strong>User<\/strong>: The username of the user who owns the process.<\/li>\n<li><strong>Command<\/strong>: The command line that launched the process.<\/li>\n<li><strong>Swap<\/strong>: How much swap space the process is using.<\/li>\n<li><strong>USS<\/strong>: The Unique Set Size.<\/li>\n<li><strong>PSS<\/strong>: The Proportional Set Size.<\/li>\n<li><strong>RSS<\/strong>: The Resident Set Size.<\/li>\n<\/ul>\n<p>To see the sizes expressed as percentages, use the <code>-p<\/code> (percentage) option.<\/p>\n<pre>smem -p<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-773189\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/12\/9.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Using the smem -p option to request percentages\" width=\"644\" height=\"55\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The sizes in bytes have been replaced with percentages.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-773191\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/12\/10.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"smem output showing percentages\" width=\"644\" height=\"336\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>To see the figures rendered in a more human-friendly form, use the <code>-k<\/code> (abbreviate) option. This shrinks the figures and adds unit indicators.<\/p>\n<pre>smem -k<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-773193\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/12\/11.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Using the smem -k option to show sizes with unit indicators\" width=\"644\" height=\"55\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Instead of raw bytes, the sizes are shown in megabytes, gigabytes, and so on.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-773194\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/12\/12.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"smem output using unit indicators like K, M, and G\" width=\"644\" height=\"333\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>To add a totals line, use the <code>-t<\/code> (totals) option.<\/p>\n<pre>smem -k -t<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-773196\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/12\/13.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Using the smem -t option to add a totals line to the output\" width=\"644\" height=\"55\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The last line of the output shows totals for each column.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-773197\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/12\/14.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"The totals line at the bottom of the smem output\" width=\"644\" height=\"336\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<h2 id=\"refining-the-report\"><span class=\"ez-toc-section\" id=\"Refining_the_Report\"><\/span>Refining the Report<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>You can ask <code>smem<\/code> to report on the memory usage by users, mapping (libraries), or system-wide.\u00a0To filter the output by user use the <code>-u<\/code> (user) option. Note that if you want to see more than just your own usage, you\u2019ll need to run <code>smem<\/code> with <code>sudo<\/code> .<\/p>\n<pre>smem -u<\/pre>\n<pre>sudo smem -u<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-773201\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/12\/15.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Using the smem -u option with and without sudo\" width=\"644\" height=\"365\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>As you can see, the output gets bent out of shape for user names longer than eight characters.<\/p>\n<p>To see the usage mapped to the libraries that are in use, regardless of which processes are using the libraries, nor which users own those processes, use the <code>-m<\/code> (mapping) option.<\/p>\n<pre>smem -m -k -t<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-773203\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/12\/16.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Using the smem -m option to get a mapper report\" width=\"644\" height=\"55\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>We also asked for human-readable values and a total.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-773205\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/12\/17.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"The smem mapped report showing the memory usage by libraries\" width=\"644\" height=\"380\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><br \/>\nTo see the system-wide memory usage use the <code>-w<\/code> (system-wide) option.<\/p>\n<pre>smem -w -k -t<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-773207\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/12\/18.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"The smem system-wide report\" width=\"644\" height=\"210\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<h2 id=\"reporting-on-a-single-program\"><span class=\"ez-toc-section\" id=\"Reporting_on_a_Single_Program\"><\/span>Reporting on a Single Program<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>With a little bit of command-line magic, we can report on a single program and all of its sub-processes. We\u2019ll pipe the output from\u00a0<code>smem<\/code> into <code>tail<\/code>\u00a0 and ask <code>tail<\/code> to only show the last line. We\u2019ll tell <code>smem<\/code> to use human-readable values and to provide a total. The total will be the last line, and that\u2019s the line <code>tail<\/code> will display for us.<\/p>\n<p>We\u2019ll use the <code>-c<\/code> (columns) option with <code>smem<\/code> and tell it which columns we want to be included in our output. We\u2019ll restrict this to the Proportional Set Size column. The <code>-P<\/code> (process filter) option allows us to give a search string to <code>smem<\/code> . Only matching lines of output will be included.<\/p>\n<pre>smem -c pss -P firefox -k -t | tail -n 1<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-773209\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/12\/19.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Using smem to show the memeory usage by a process and its children\" width=\"644\" height=\"95\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>That\u2019s a quick and neat way to find out the RAM consumption of a program and its child processes.<\/p>\n<h2 id=\"generating-graphs\"><span class=\"ez-toc-section\" id=\"Generating_Graphs\"><\/span>Generating Graphs<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>You can pass the <code> --pie<\/code> or <code>--bar<\/code> options to have <code>smem<\/code> generate graphs. It has to be said that with too many categories the graphs quickly become unintelligible, but they can be useful for a quick visual overview.<\/p>\n<p>The command format is:<\/p>\n<pre>smem --pie name -s uss<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-773212\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/12\/20.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Asking smem to produce a pie chart\" width=\"644\" height=\"55\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The pie chart appears in its own viewer window.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-773216\" data-pagespeed-lazy-src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/12\/21.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"An smem pie chart in its own viewer window\" width=\"600\" height=\"450\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>To see other plots, use <code>pss<\/code> or <code>rss<\/code> instead of <code>uss<\/code>. To see a bar graph, use <code>--bar<\/code> instead of <code>--pie<\/code>.<\/p>\n<p>For this to work you\u2019ll need to have Python installed, along with the <code>matplotlib<\/code>\u00a0library. These were already installed on the Ubuntu, Fedora, and Manjaro distributions we tested.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Good_Things_Come_In_Small_Packages\"><\/span>Good Things Come In Small Packages<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The <code>smem<\/code>\u00a0utility has a few more tricks up its sleeve, and you\u2019re encouraged to check out its <code>man<\/code> page. Its main repertoire is what we\u2019ve outlined here, and it\u2019s a great little tool to have in your CLI toolbox.<\/p>\n<p><strong>RELATED:<\/strong> <strong><em>37 Important Linux Commands You Should Know<\/em><\/strong><\/p>\n<\/div>\n<p><script>\n setTimeout(function(){\n  !function(f,b,e,v,n,t,s)\n  {if(f.fbq)return;n=f.fbq=function(){n.callMethod?\n  n.callMethod.apply(n,arguments):n.queue.push(arguments)};\n  if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';\n  n.queue=[];t=b.createElement(e);t.async=!0;\n  t.src=v;s=b.getElementsByTagName(e)[0];\n  s.parentNode.insertBefore(t,s) } (window, document,'script',\n  'https:\/\/connect.facebook.net\/en_US\/fbevents.js');\n   fbq('init', '335401813750447');\n   fbq('track', 'PageView');\n  },3000);\n<\/script><\/p>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.howtogeek.com\/773161\/easily-understand-your-linux-ram-usage-with-smem\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#Easily Understand Your Linux RAM Usage With Smem&#8221; fatmawati achmad zaenuri\/Shutterstock Linux memory usage can be difficult to interpret and hard to understand. With smem it\u2019s easy to find out what memory a process is using, and which processes are using the most. Memory Usage Linux gives you many ways to check what\u2019s happening with&#8230;<\/p>\n","protected":false},"author":1,"featured_media":395417,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2021\/11\/hero-1.png?height=200p&trim=2,2,2,2","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-395416","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/395416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=395416"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/395416\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/395417"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=395416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=395416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=395416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}