How to manage memory to restrict Linux to use too much RAM
You install Linux with the promise that it will consume less system resources than Windows. But why then, is your system still slow?
Do not panic! Linux does not consume your RAM. To understand what's going on, consider how Linux manages memory.
How Linux manages memory
- How to see the RAM available on Linux
- How Linux uses RAM
- The difference between available RAM and available RAM
- How to clear cache RAM and buffer
- How to view and close programs
How to see the RAM available on Linux
As with anything else on Linux, there are many ways to check the amount of RAM being used. If you have a commercial operating system, you can easily do this through an application like the Windows Task Manager or macOS Activity Monitor . This program name depends on the Linux desktop environment you use.
On GNOME, the most widely used option is to open a program called System Monitor. On KDE, there is an entirely similar alternative to Konsole. Other desktop environments have similar tools under different names.
To find an approach that works regardless of your computer environment, you can switch to using the command line. Open the Terminal application and type the following command.
free
You will see the results look like the following. The numbers will vary depending on the amount of RAM on your device and the number of active programs.
For a more detailed view of RAM on your device, try this:
cat /proc/meminfo
The above command loads the same file that the free command uses to see how much memory is available on your PC.
If your numbers are not reasonable, then it seems that Linux is consuming your RAM. Suppose you have 4GB of RAM and 3.9GB in use. Only 0.1GB of free space is available for additional applications!
This time, look at the 'available' column . There, you can see that you actually have 1GB of open data for the application. But how? All are geared towards how Linux manages and uses RAM.
How Linux uses RAM
The way Linux uses RAM is not much different from Windows and other operating systems. But different systems show what is happening in different ways.
When your computer finds that there is currently no RAM in use, it spends some of this space for the disk cache. In this way, the application stores data in a more accessible location, making the system run faster and smoother. When other applications need more memory, they take the amount of applications needed from this disk cache.
In other words, Linux uses that free space very well while it 'rests'. Why leave all that free memory space wasted?
To know how much memory space is used in this way, look at the 'buff / cache' column . This is the amount of RAM reserved for the buffer (temporary data) and cache (cache) at the time you run the command. The idea that deleting this space can help increase performance is a common misconception about RAM.
The difference between available RAM and available RAM
These two concepts are easily confused. This is how Linux considers your RAM.
- Used ( Used ): RAM is currently being used by the application.
- Available ( Available ): RAM can be used for caching on the drive but can be freed for applications.
- Free (empty): RAM is not used by an application or disk cache.
Free and available seem like synonyms, but they have technical differences. Free is memory that is not used. Available is memory currently in use, but can be easily switched for use if needed. For daily use, the amount of available memory is really important.
How to clear cache RAM and buffer
Suppose, for some reason, you still want to delete the RAM that the Linux kernel is using for its cache and buffer. In fact, doing this will negatively impact performance. If you want your system to run optimally, leave everything in its place.
You will run these commands as a system administrator.
To delete pagecache, enter the following command:
echo 1 > /proc/sys/vm/drop_caches
To delete dentries and inodes, enter the following command:
echo 2 > /proc/sys/vm/drop_caches
To delete all pagecache, dentries and inodes together, enter the following command:
echo 3 > /proc/sys/vm/drop_caches
If these commands do not improve PC performance, why run them? Doing so is to compare your computer's performance after making changes without having to restart. If you don't measure or test your PC, there's very little reason to touch these parts.
How to view and close programs
All of this means you don't need to check RAM and manage memory on Linux? Not really.
Although Linux knows how to optimize RAM, that doesn't mean your application is the same. Sometimes your browser will take up all the memory. A game can take over and not release any system resources. The image viewer can be suspended when trying to load an extremely large image.
To see which programs are causing your computer problems, try the following top command:
top
The result will look like this:
Now that you have discovered a problematic program, what can you do with it? One option is to use the kill command . To do so, note that the PID number appears next to the program when you enter the top command . You will need it.
kill -9 2470
Alternatively, you can use the killall command to close the program with its name.
killall firefox
Unlike many things in life, your computer memory can be more or less self-managed. Here, the article looks at ways to find out what's going on and when users need to act. Now, you know how to see how much memory is using and which program is using it. You can also take a few steps to stop tasks that are taking up too much memory space.
Good luck!
See more:
- 8 easy ways to free RAM make the machine run faster
- Top 5 RAM optimization software, enhance computer performance
- Causes for computers to be "slow like turtles"
You should read it
- Clear the Dropbox cache Windows and Linux to free up memory space
- 14 interesting Linux commands in Terminal
- Basic Linux commands everyone needs to know
- How does the Linux Kernel work?
- Compare the most popular Linux distributions today
- 7 best Linux distributions based on Red Hat
- How to completely delete a file in Linux so that it cannot be restored
- 8 main differences between Windows and Linux
- What's new in Linux Kernel 5.18?
- 6 reasons why the Linux operating system often fails
- How to manage photos on Linux
- 8 best Linux distros for pentest
Maybe you are interested
Tips for naming Instagram with impressive and unique names
How to schedule messages on Instagram
How to create a 2024 collage on Instagram
Benchmark the 4 most popular browsers today to see which one is faster and consumes less RAM
Difference between arguments and parameters in C/C++
How to delete Instagram Story very fast