Fix high memory usage in Debian

Chưa phân loại
Memory overload is among the main causes of device failures. Memory high usage may be caused by different reasons. This tutorial shows how to check for processes usage, used and free space and how to analyze your hardware to diagnose physical problems.

The first chapter is a fast view over commands free, top, ps and /proc/meminfo, following common troubleshooting commands including cleaning the cache, killing processes and ram memory tests for hardware issues which is the less probable scenario, each command is deeply explained with examples on additional articles numerated on the Related articles section at the bottom.

Monitoring memory usage in Debian

Below a list with examples of commands used to monitor the memory usage on Debian and other Linux distributions. The first command in the list is free, without parameters the default output unit is kb. To display it on the console run:

/# free

this row shows the physical ram memory
this row displays information on the virtual memory (swap)
this column shows the total capability
this column shows the amount of memory or swap being used

Free: the unused ram memory or swap
memory shared to be used by multiple processes
temporary store of pseudo files on memory to be used by processes
the available memory for processes

To print the output in MB units use the -m flag:

/# free -m

You can display the man page by running:

/# man free

Another way to check the memory usage is by reading the file /proc/meminfo, you can use the command less or open the location /proc/meminfo on a browser.
The file /proc/meminfo runs on memory and provides information on the memory use such as free, used, swap, buffers and shared memory.

/# less /proc/meminfo

The top command allows to monitor memory usage in real time through an interactive console interface. Through it you can kill and edit the view in real time. When displaying the top interactive console you can browse between processes and select them using the keyboard arrows or kill them using the k key. The following example shows the default output for the top command without flags:

/# top


PID: this column shows the process ID number.
USER: this column shows the user who runs the process.
PR: prioriory for running processes.
NI: nice value
VIRT: Virtual Memory (Swap) being used.
RES: Physical memory used.
SHR: Shared memory used.
S: Process status.
%CPU: amount of CPU used by the process.
%MEM: amount of RAM memory used by the process
TIME+: total time the process is running.
COMMAND: the program or command which executes the process.

The article How to Check Memory Usage Per Process on Linux shows an interesting use of the ps command to print processes and their memory usage:

/# ps -o pid,user,%mem,command ax | sort -b -k3 -r

Then you can kill the process eating your memory, make sure the process doesn’t launch automatically at the startup.

How to fix high memory usage in Debian

This chapter shows some commands to solve high memory usage problems.
Before running the following steps always monitor the process status if possible by using any of the command shown previously.

Fixing high memory usage problems on Linux depends on the program the process consuming memory belongs. Usually after identifying it you can kill it or fix the problem causing the high usage.

The first command shows how to release memory from the cache, you can see the comparison of the free -m output before and after running the command:

/# echo 3 > /proc/sys/vm/drop_caches

As you can see in the free -m executed before and after the command the buff/cache column shows a decrease from 996 to 603 and additional memory became available.

Testing Memory Hardware in Debian

This chapter shows how to analyze your ram memory for hardware issues.
The optimal way to test the ram memory is by booting the computer using the memtester feature instead of the OS granting Memtest greater access to the memory. When executed from the OS the effectivity decreases. To install memtester on the console run:

/# apt install memtester

To run memtest you should specify the memory size in kb and the number of times you want tests to run.

/# memtester 16384 5

The following tests are from the original version, updated simply for speed and rewritten to fit the new framework of the program.  These tests will mainly catch memory errors due to bad bits which are permanently stuck high or low:

Random Value

Compare XDR
Compare SUB
Comprate MUL
Compare DIV
Compare OR
Compare AND

The following tests were implemented by me, and will do a slightly better job of catching flaky bits, which may or may not hold a true value:

Sequential Increment
Solid bits
Block Sequential


I hope you found this tutorial on fixing high memory usage on Debian useful. Keep following LinuxHint for more tips and updates on Linux and networking.

Related articles:

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Hướng dẫn cài đặt Pritunl VPN trên Onet

Mục lục 1. Mô hình cài đặt 2. Mục tiêu sử dụng 3. Yêu cầu cấu hình 4. Cài đặt...

Basic Linux Network Commands

The ip command The ifconfig command The iwconfig command The dhclient command The route command The host command The netstat...

How to Install the Latest MySQL 8 on Debian 10 Buster

This tutorial explains how to install Mysql 8 on Debian 10 Buster but it is also useful for previous Debian versions, while...
Bài Viết

Bài Viết Mới Cập Nhật


Mua Proxy v6 US Private chạy PRE, Face, Insta, Gmail

Mua shadowsocks và hướng dẫn sữ dụng trên window

Tại sao Proxy Socks lại được ưa chuộng hơn Proxy HTTP?

Mua thuê proxy v4 nuôi zalo chất lượng cao, kinh nghiệm tránh quét tài khoản zalo