1. Overview

Sometimes, our systems feel sluggish, and performance slows down for no apparent reason. Often, this is due to memory issues, as memory is crucial for a system’s performance and stability. Monitoring memory usage can be very helpful in troubleshooting these issues.

We can always check memory usage with the Ubuntu system monitor. However, having it displayed on the top panel of the desktop keeps the information always visible.

In this tutorial, we’ll explore how to show memory usage in the top bar or as a notification in Ubuntu. We’ll cover an open-source application and some Gnome extensions.

2. Show Memory Usage Using the System Load Indicator Application

System Load Indicator is a free and open-source application that displays the graphical usage of various system resources, such as memory, CPU, network upload and download speed, and swap usage. This application is available in the official Linux repositories.

We can install the System Load Indicator application using apt:

$ sudo apt install indicator-multiload

Once installed, we can launch the System Load Indicator utility from the Applications menu. We press the Super key on the keyboard, type System Load Indicator in the search bar, and click the application when it appears in the search results. This will display the resource usage in the top menu bar.

The System Load Indicator Application displays the usage of all resources such as CPU, memory, and swap. To display only the memory usage in the top bar, we’d need to make some configuration changes. To do so, we click the System Load Indicator icon in the top menu bar to open a menu, then we click on Preferences:

System Load Indicator Preferences

This will open the indicator-multiload window. We click on Indicator items in its bottom menu:

Indicator items

We want only memory usage to appear in the menu bar, therefore, let’s select Mem $(size(mem.user)) and click Up:

bring memory usage at top

This will bring the Memory indicator to the top of the list.

Now, we can see the memory usage in the top menu bar on our desktop:

memory usage at top bar

By clicking it, we can view the usage of other resources like CPU, network, swap, etc.

3. Show Memory Usage Using Gnome Shell Extensions

In Linux, there are multiple Gnome shell extensions available to display memory usage in the top bar of the desktop. These extensions provide a quick and easy way to monitor the system’s resource usage. In Ubuntu, we can install and manage Gnome shell extensions using the Gnome Shell Extension Manager.

Let’s first install the Gnome Shell Extension Manager on our system using apt:

$ sudo apt install gnome-shell-extension-manager

Once installed, we can use the Extension Manager to add different extensions that show memory usage in the top bar of our system.

3.1. Using the system-monitor-next Extension

The system-monitor-next extension shows system-related information such as CPU, memory, and disk utilization in the top bar of the Ubuntu desktop. We can also configure it to show only the memory usage.

Let’s install the system-monitor-next extension on our Ubuntu system along with some prerequisites:

$ sudo apt install gir1.2-gtop-2.0 gir1.2-nm-1.0 gir1.2-clutter-1.0 gnome-system-monitor

Then, we open the browser and navigate to the system-monitor-next extension page. Next, we click the toggle to enable the extension. It prompts us for the installation of the extension. We click Install to download and install the system-monitor-next extension on our system. Once installed, it starts displaying the system’s resource usage information in the top bar of the desktop.

Now, as we want to show only the memory usage information in the top bar, we’ll have to configure the settings. Let’s click on the system-monitor-next icon in the top bar and select Preferences:

simple-monitor-next Extension Preferences

Then in the Preferences window, we click on the Memory tab. Here, we can select the display style for memory usage, such as digital or graphical display. Then, we go to other tabs like CPU, Freq, Memory, and Swap, one by one and uncheck the Display box to hide them from displaying in the top bar:

simple-monitor-next Extension Memory tab

Now, let’s look at the results:

show memory usage on top bar

We can see that it’s now displaying only the memory usage on our top bar.

3.2. Using the just-shows-memory-usage Extension

just-shows-memory-usage is another simple Gnome extension that only shows memory usage in the top bar of the Ubuntu desktop. To install this extension, we visit the just-shows-memory-usage extension page and click the toggle to enable the extension. Then, a prompt will appear. Next, we click the Install button to download and install the extension on our system.

After the installation is completed, it’ll start displaying the system’s memory usage on the top bar of our desktop:

Just Shows Memory Usage extension

The screenshot shows that 1.24G of the total 1.88G memory is currently in use.

3.3 Using the Gnome-Stats-Pro Extension

Gnome-Stats-Pro is another simple extension that shows CPU and memory usage in the top bar in Ubuntu. The installation process is the same as any other Gnome extension. First, we visit the official Gnome-Stats-Pro extension page. Then, we enable the extension by clicking the toggle button. After that, an installation prompt appears enabling us to proceed with the installation.

Once the installation is completed, we’ll see a graph in the top bar of our desktop. Hovering over it shows the current memory usage along with the usage of other resources:

gamestatspro extension showing memory usage

This shows the total memory is 1922.41 MiB, the current memory usage is 1797.06 MiB, and free memory is 65.18 MiB, along with some other details.

3.4. Using the Simple Monitor Extension

Let’s discuss another Gnome extension known as Simple Monitor extension that shows memory and CPU usage in percentage at the top panel of the desktop. Additionally, if we click the extension icon, it shows the top 10 CPU and top 10 memory-consuming processes.

To install this extension, we visit the Simple Monitor Gnome page. Then, we toggle the button in front of the extension to enable it. This will ask for the installation of the extension. To download and install the extension, we click the Install button.

After installing the Simple Monitor extension, we’ll see the memory and CPU usage percentage at the top panel of our Ubuntu desktop. We can click it to see which processes are consuming the most of our system’s memory:

simple monitor extension

In the above output, we can see the top 10 processes consuming the most memory on our system.

4. Show Notifications on High Memory Usage

In addition to displaying memory usage, we can also set up desktop notifications when memory usage on our system exceeds a specific limit. This can help us take timely action and ensure smooth system operations. We can do this using a simple script and cron job.

First, we create a script named mem_script.sh:

$ cat mem_script.sh

#!/bin/bash

THRESHOLD=70

MEMORY_USAGE=$(free | grep Mem | awk '{print $3/$2 * 100.0}')

if (( ${MEMORY_USAGE%.*} > THRESHOLD )); then

notify-send "Memory Alert" "Memory usage is at ${MEMORY_USAGE}%"

fi

Let’s briefly understand the code. The THRESHOLD variable is the percentage of memory usage that, when exceeded, triggers a desktop notification. The MEMORY_USAGE variable saves the memory usage as a percentage. The if statement checks if the memory usage percentage exceeds the threshold 70, and sends a notification with the message specified in the notify-send command.

Now, let’s make this script executable:

$ chmod +x ~/mem_script.sh

Next, we create a cron job to run this script at specific times:

$ crontab -e

Let’s say we want to run this script every 5 minutes. Therefore, we’ll add:

*/5 * * * * ~/mem_script.sh

Then, save and close the file.

Now, the cron job will check the memory usage every 5 minutes and will notify if the memory exceeds the specified limit which is 70%.

5. Conclusion

In this article, we’ve covered several ways to display memory usage in the top bar of Ubuntu desktop. This included one application and a few Gnome extensions. Additionally, we discussed how to get notifications when our system’s memory exceeds a specific threshold.

Using these methods, we can monitor system performance more effectively and address memory issues quickly.