Check the memory usage of a specific process in Linux.
In Linux, you can use the top or htop command to check the memory usage of a specific process.
- Use the top command:
- Open the terminal and type in the top command.
- Press Shift + f, then press the n key, select the %MEM option, and press Enter.
- Press Shift + r, then input the process’s PID (Process ID) and press Enter.
- The top command will display the memory usage of the process.
- Execute the htop command (htop needs to be installed beforehand):
- Open the terminal and enter the htop command.
- Press the F6 key and then type MEM% followed by pressing the Enter key.
- Press the F4 key, then enter the PID (Process ID) and press Enter.
- The htop command displays the process’s memory usage.
Additionally, you can use the combination of the ps command and grep command to view the memory usage of a specified process.
ps aux | grep <进程名或PID>
The above command will list the processes associated with the specified process name or PID, including memory usage information.