How to check memory usage on Ubuntu 22.04

If you’re a fan of Ubuntu 22.04, the popular Linux distro with its slick user-friendly interface and powerful features, you might be wondering how to keep tabs on your system’s memory usage to keep things running smoothly. After all, keeping an eye on memory usage is key to spotting any potential bottlenecks and optimizing your system’s performance.

In this all-inclusive guide, we’ll take a deep dive into various methods for checking memory usage in Ubuntu 22.04. We’ll cover both command-line tools and graphical user interface (GUI) options, providing you with step-by-step instructions and handy tips and tricks along the way. So, let’s jump in and learn how to efficiently monitor memory usage in Ubuntu 22.04.

Checking Memory Usage via Command-Line

Ubuntu has got you covered with a range of handy built-in command-line tools that let you keep an eye on your system’s memory usage. These tools offer in-depth insights into how much memory different processes or applications are gobbling up, so you can pinpoint any memory hogs that might be slowing things down.

Read: How to fix high memory usage in Linux

Using the “free” Command

The “free” command is a nifty tool that provides comprehensive insights into how your system’s memory is being used. Here’s how you can put it to work in Ubuntu 22.04:

Pop open a terminal window by hitting Ctrl+Alt+T or by hunting down “Terminal” in the Ubuntu applications menu.

Inside the terminal, type the following command and hit Enter:

free -h

Check memory usage on Linux

The “-h” option makes the output easy to read, showing memory usage in a more user-friendly format.

The “free” command will spill the beans on your system’s memory usage, including total memory (in the “total” column), used memory (in the “used” column), free memory (in the “free” column), shared memory (in the “shared” column), and buffer/cache memory (in the “buff/cache” column).

Read: How to Check Disk Space in Ubuntu 22.04

You can also check out memory usage in different units like bytes, kilobytes, megabytes, or gigabytes by using the appropriate options with the “free” command. For instance, to see memory usage in gigabytes, you can use this command:

free -g

Using the “top” Command

The “top” command is a powerful tool that provides real-time information about system processes, offering insights into memory usage and other important metrics. Follow these steps to utilize the “top” command in Ubuntu 22.04:

  1. Open a terminal window to access the command line interface.
  2. In the terminal, enter the command “top” and press Enter.
  3. The “top” command will present a live updating list of processes currently running on your system, arranged by various criteria such as CPU usage, memory usage, and more.
  4. To view the processes sorted by memory usage, simply press “Shift” + “M”. This will rearrange the processes in descending order based on their memory consumption.
  5. Further customization of the “top” command display is possible using various options. For instance, to view memory usage in kilobytes, you can use the following command: “top -o RES”.
  6. The “-o” option, followed by “RES”, specifies that the processes should be sorted by resident memory usage

Read: 12 Linux Basic Health Check Commands for Monitoring Performance

Using the “ps” Command

The “ps” command is a handy tool that provides valuable insights into system processes and their memory usage, making it a powerful tool for Ubuntu 22.04 users. To make the most of this command, simply follow these easy steps:

  1. Open a terminal window in Ubuntu.
  2. Enter the following command in the terminal and press Enter:
    ps aux –sort=-%mem

The “ps” command, when used with the “aux” options, generates a comprehensive list of all processes currently running on your system, complete with detailed information such as user, process ID (PID), CPU usage, and memory usage. By including the “–sort=-%mem” option, the processes are sorted in descending order based on their memory usage, allowing for easy identification of memory-intensive processes.

Linux memory check

Upon execution, the “ps” command displays the list of processes sorted by memory usage, with the process consuming the most memory listed at the top. This provides a quick and efficient overview of memory utilization by different processes, making it useful for system performance analysis and optimization.

Read: 4 Ways to Find Large Files on Linux and Free Up Disk Space

Using /proc/meminf

To retrieve memory-related information from the /proc file system, you can use the following command. These files contain live information about the system and the kernel, as opposed to actual system files.

Here’s the command to display memory information:

cat /proc/meminfo

You can use /proc/meminfo to obtain detailed memory usage information. The output of this command is similar to the vmstat command, allowing you to easily view the amount of free memory in the MemFree result and the free swap memory in the SwapFree result.

Checking Memory Usage via Graphical User Interface (GUI)

If you’re more of a visual person, Ubuntu 22.04 also offers GUI tools to check memory usage. These tools provide a graphical representation of memory usage, making it simpler to grasp the information at a glance..

Using the System Monitor

The System Monitor is a great tool built right into Ubuntu, called a graphical user interface (GUI), that gives you a visual representation of how your system processes and resources, like memory, are being used. To access and use the System Monitor in Ubuntu 22.04, follow these simple steps:

  1. Find the “System Monitor” in the applications menu in Ubuntu, or simply press Ctrl+Alt+Del and choose “System Monitor” from the options.
  2. Once you’re in the System Monitor window, head over to the “Resources” tab.
  3. In the “Resources” tab, you’ll get a comprehensive overview of memory usage, including total memory, used memory, free memory, and buffer/cache memory. This information is presented in an easy-to-understand graphical format, so you can quickly grasp the situation.
  4. If you need more detailed insights into specific processes and their memory usage, just click on the “Processes” tab in the System Monitor window. There, you’ll find a list of processes along with their corresponding memory usage, which makes it a breeze to identify any memory-hogging processes.

Read: How to Configure Network Settings in Ubuntu 22.04

Using GNOME System Monitor

If you’re using the GNOME desktop environment in Ubuntu 22.04, there’s another handy tool available: the GNOME System Monitor. It’s similar to the System Monitor and provides a graphical representation of system processes and resources, including memory usage. Here’s how you can use it:

  1. Get the GNOME System Monitor up and running by searching for “System Monitor” in the Ubuntu applications menu or by pressing Ctrl+Alt+Del and selecting “System Monitor” from the options.
  2. Once you’re in the GNOME System Monitor window, head straight to the “Resources” tab.
  3. In the “Resources” tab, you’ll find detailed information about memory usage, just like in the System Monitor. However, here it’s presented in a visual graph that makes it super easy to understand at a glance.
  4. Need more specifics about individual processes and their memory usage? No worries! Just click on the “Processes” tab in the GNOME System Monitor window to get all the juicy details.

Additional methods

In addition to the tools and methods we’ve mentioned earlier, here are some extra tips and tricks for keeping tabs on memory usage in Ubuntu 22.04:

  • Use the “htop” command: “htop” is a powerful command-line tool that gives you an interactive and user-friendly way to check system processes, including memory usage. You can easily install “htop” by running this command:

sudo apt-get install htop

  • Once it’s installed, you can fire up “htop” in the terminal and get detailed information about system processes, sorted by various criteria, including memory usage.
  • Keep an eye out for memory leaks: Memory leaks are software bugs that can hog memory by allocating it but not releasing it, resulting in excessive memory usage over time. It’s crucial to check your system for memory leaks and fix any potential issues. Tools like “valgrind” or “memtest86+” can be handy for detecting memory leaks and optimizing memory usage.
  • Shut down unnecessary applications/processes: Closing applications or processes that consume excessive memory can significantly boost your system’s performance. Regularly review and shut down any unnecessary applications or processes that are running in the background but not in use to free up memory.
  • Disable unnecessary services: Ubuntu 22.04 might have default services running that are not needed for your specific requirements. Disabling unnecessary services can help reduce memory usage. You can manage services and disable the ones you don’t need using the “systemctl” command.
  • Keep a close watch on memory usage: Regularly monitoring memory usage in Ubuntu 22.04 is important to catch any potential issues and take necessary actions. By keeping an eye on memory usage, you can proactively address performance or memory-related concerns.

Ubuntu memory check

Read: Monitoring system processes in Ubuntu using htop

FAQs

Here are some frequently asked questions related to checking memory usage in Ubuntu 22.04:

Q: How do I Interpret “Free” Command’s Memory Usage Info?

A: The “free” command shows memory usage in KB, MB, and GB. The “total” column displays the physical memory in your system, “used” shows the memory currently in use, “free” indicates unused memory, while “shared” and “buff/cache” denote memory used for shared libraries and file system buffers/cache.

Q: What’s “Swap” Memory and How Does It Affect Ubuntu 22.04?

A: “Swap” memory is part of the hard drive used as virtual memory when RAM is full. Ubuntu 22.04 relies on swap memory as a backup when RAM is exhausted. However, swap memory can significantly slow down system performance compared to physical memory. Monitoring swap memory usage and optimizing it can prevent excessive swapping, which impacts system performance.

Q: Can I Upgrade My System’s Memory for Better Performance?

A: Absolutely! Upgrading your system’s RAM can greatly boost performance, especially if you face frequent memory-related issues. Ubuntu 22.04 has specific memory requirements, so upgrading to meet or exceed them can ensure smooth performance.

Conclusion

keeping tabs on memory usage in Ubuntu 22.04 is essential for keeping an eye on system performance and catching potential memory-related issues. Whether you prefer command-line tools or graphical user interface (GUI) options, Ubuntu 22.04 offers various ways to check memory usage. Utilizing the “free” command, “ps” command, System Monitor, GNOME System Monitor, or other tools, you can effortlessly monitor memory usage and take necessary steps to optimize system performance. It’s also important to regularly review and manage memory usage by closing unnecessary applications/processes, disabling unnecessary services, and keeping an eye on swap memory. Remember, optimizing memory usage is just one piece of the puzzle for system performance management. Regular system updates, software optimizations, and hardware upgrades (if needed) should also be considered for peak performance. By being proactive in monitoring and optimizing memory usage, you can enjoy a smooth and efficient experience with Ubuntu 22.04.

 


If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.

 

Nikolaus Oosterhof

Nikolaus holds a degree in software development and has a strong passion for all things tech-related, especially gadgets with screens. Though he is nostalgic for older phone models, he's a retired gamer and continues to enjoy programming in open-source environments. Additionally, Nikolaus enjoys writing about Linux, macOS and Windows and has experience designing web pages.

Leave a Reply