Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fedora - Understand Fedora memory usage with top

#1
Understand Fedora memory usage with top

<div style="margin: 5px 5% 10px 5%;"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2018/09/understand-fedora-memory-usage-with-top.png" width="710" height="430" title="" alt="" /></div><div><p>Have you used the <em>top</em> utility in a terminal to see memory usage on your Fedora system? If so, you might be surprised to see some of the numbers there. It might look like a lot more memory is consumed than your system has available. This article will explain a little more about memory usage, and how to read these numbers.</p>
<p><span id="more-22641"></span></p>
<h2>Memory usage in real terms</h2>
<p>The way the operating system (OS) uses memory may not be self-evident. In fact, some ingenious, behind-the-scenes techniques are at play. They help your OS use memory more efficiently, without involving you.</p>
<p>Most applications are not self contained. Instead, each relies on sets of functions collected in libraries. These libraries are also installed on the system. In Fedora, the RPM packaging system ensures that when you install an app, any libraries on which it relies are installed, too.</p>
<p>When an app runs, the OS doesn’t necessarily load all the information it uses into real memory. Instead, it builds a map to the storage where that code is stored, called <em>virtual memory</em>. The OS then loads only the parts it needs. When it no longer needs portions of memory, it might release or swap them out as appropriate.</p>
<p>This means an app can map a very large amount of virtual memory, while using less real memory on the system at one time. It might even map more RAM than the system has available! In fact, across a whole OS that’s often the case.</p>
<p>In addition, related applications may rely on the same libraries. The Linux kernel in your Fedora system often shares memory between applications. It doesn’t need to load multiple copies of the same library for related apps. This works similarly for separate instances of the same app, too.</p>
<p>Without understanding these details, the output of the <em>top</em> application can be confusing. The following example will clarify this view into memory usage.</p>
<h2>Viewing memory usage in <em>top</em></h2>
<p>If you haven’t tried yet, open a terminal and run the <em>top</em> command to see some output. Hit <strong>Shift+M</strong> to see the list sorted by memory usage. Your display may look slightly different than this example from a running Fedora Workstation:</p>
<p><a href="http://www.sickgaming.net/blog/wp-content/uploads/2018/09/understand-fedora-memory-usage-with-top.png"><img class="aligncenter size-full wp-image-22642" src="http://www.sickgaming.net/blog/wp-content/uploads/2018/09/understand-fedora-memory-usage-with-top.png" alt="" width="710" height="430" /></a></p>
<p>There are three columns showing memory usage to examine: <em>VIRT, RES, </em>and <em>SHR</em>. The measurements are currently shown in kilobytes (KB).</p>
<p>The VIRT column is the virtual memory mapped for this process. Recall from the earlier description that virtual memory is not actual RAM consumed. For example, the GNOME Shell process <em>gnome-shell</em> is not actually consuming over 3.1 gigabytes of actual RAM. However, it’s built on a number of lower and higher level libraries. The system must map each of those to ensure they can be loaded when necessary.</p>
<p>The RES column shows you how much actual <em>(resident)</em> memory is consumed by the app. In the case of GNOME Shell, that’s about 180788 KB. The example system has roughly 7704 MB of physical memory, which is why the memory usage shows up as 2.3%.</p>
<p>However, of that number, at least 88212 KB is <em>shared</em> memory, shown in the SHR column. This memory might be, for example, library functions that other apps also use. This means the GNOME Shell is using about 92 MB on its own not shared with other processes. Notice that other apps in the example share an even higher percentage of their resident memory. In some apps, the shared portion is the vast majority of the memory usage.</p>
<p>There is a wrinkle here, which is that sometimes processes communicate with each other via memory. That memory is also shared, but can’t necessarily be detected by a utility like <em>top</em>. So yes — even the above clarifications still have some uncertainty!</p>
<h2>A note about swap</h2>
<p>Your system has another facility it uses to store information, which is <em>swap</em>. Typically this is an area of slower storage (like a hard disk). If the physical memory on the system fills up as needs increase, the OS looks for portions of memory that haven’t been needed in a while. It writes them out to the swap area, where they sit until needed later.</p>
<p>Therefore, prolonged, high swap usage usually means a system is suffering from too little memory for its demands. Sometimes an errant application may be at fault. Or, if you see this often on your system, consider upgrading your machine’s memory, or restricting what you run.</p>
<hr />
<p><em>Photo courtesy of <a href="https://www.flickr.com/photos/stignygaard/">Stig Nygaard</a>, via <a href="https://www.flickr.com/photos/stignygaard/3138001676/">Flickr</a> (CC BY 2.0).</em></p>
</div>
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB Theme © iAndrew 2016