Javatpoint Logo
Javatpoint Logo

Linux Process Memory Usage

Determining the program often needs detecting the memory usage of the system, which consumes all CPU resources or the program which is responsible for slowing down the CPU's activities. Tracing process memory usage is essential in order to specify the load on the server. By parsing usage data, the servers can balance the load without slowing down the system and serving the user's request.

Commands Used to Check the Process Memory Usage in Linux

There are various commands to check process memory usage in Linux:

1. Free

This command shows the amount of memory that is presently available and used by the system for both swapped as well as physical. The free command collects this data via parsing/proc/meminfo. By default, the amount of memory is shown in kilobytes.

Linux Process Memory Usage

If we want to execute the program periodically, then we can use the watch command.

Syntax:


Linux Process Memory Usage

According to the above image, there is 3842 MB RAM and 7628 MB of swap space allotted to the Linux system. Out of 3852 MB RAM, 678 MB is presently used; however, 2373 MB is free. Correspondingly for swap space, out of 7628 MB, 0 MB is used, and 7628 MB is free presently in the system.

2. vmstat

If we want to display the virtual memory statistics of the system, then we can use the vmstat command. This command display data related to the memory, disk, paging, CPU activities etc. When we use this command the first time, then this returns averages of data since the last reboot. The next use returns the data according to the sampling periods of the length delay.

Linux Process Memory Usage

Linux Process Memory Usage

Linux Process Memory Usage

3. Top

The top command is used to show all the processes presently running in the system. The top command shows the list of thread and processes which are presently being managed by the kernel. In order to monitor the total amount of memory usage we can also use this command.

Linux Process Memory Usage

Linux Process Memory Usage

4. /proc/meminfo

This file includes all the data related to the usage of memory. It provides you the detail of current memory usage instead of the old stored values.

Linux Process Memory Usage

5. htop

It is an interactive process viewer. The Htop command is the same as top command except that we can scroll horizontally and vertically in order to permit users to view each process running on the system, with their full command line and viewing them as a tree of process, choosing processes and act on them all at once.

Linux Process Memory Usage
Next TopicLinux Tree Command




Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA