How to check memory used by a process in linux?

by aliya.yundt , in category: General Help , a month ago

How to check memory used by a process in linux?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by cathrine_goyette , a month ago

@aliya.yundt 

There are several ways to check the memory used by a process in Linux. Here are a few methods:

  1. Using the top command: Open the terminal and run the top command. Press Shift + M to sort processes by memory usage. Look for the specific process in the list, and note the memory usage column (RES or %MEM).
  2. Using the ps command: Open the terminal and run the ps aux | grep [process name] command, replacing [process name] with the name of the process you want to check. Note the value in the %MEM column.
  3. Using the pidstat command: Open the terminal and run the pidstat -r [process ID] command, replacing [process ID] with the ID of the process you want to check. Look for the %MEM column, which displays the memory usage percentage.
  4. Using the smem command: Install the smem utility by running sudo apt-get install smem in the terminal. Run the smem -p [process ID] command, replacing [process ID] with the ID of the process you want to check. Note the RSS (Resident Set Size) column, which displays the memory usage in kilobytes.


Choose the method that best suits your needs and preferences.