How to use the `free` command to check memory usage in Linux. In Linux
free Displays the amount of memory that is currently available and used by the system (both physical and swapped). free command gathers this data by parsing /proc/meminfo. By default, the amount of memory is displayed in kilobytes.
free
To display the memory usage in megabytes every 5 seconds, we use the following command. Watch command is used to execute a program periodically.
watch -n 5 free -m
Tracing memory usage in Linux
Memory is a critical resource in computing because its usage affects the performance and stability of a system. It’s necessary to trace the memory usage of the system in order to determine the program that consumes all CPU resources or the program that is responsible for slowing down the activities of the CPU.
Tracing memory usage also becomes necessary to determine the load on the server. Parsing the usage data enables the servers to be able to balance the load and serve the user’s request without slowing down the system. In Linux, there are several ways to trace memory usage, and we are going to discuss them.