In linux, how to see memory usage of a process in MB
- User
In linux, how to see memory usage of a process in MB
- Assistant
In Linux, you can use the
pscommand to see the memory usage of a process in different units, including megabytes (MB). However, thepscommand by default shows memory usage in kilobytes (KB). To convert it to MB, you can use a little bit ofawkto do the math for you.Here's an example of using
pswithawkto show the Resident Set Size (RSS) memory usage of a process in MB:ps -o pid,rss,comm -p <PID> | awk '{if(NR>1)print $1, int($2/1024)"M", $3}'Replace
<PID>with the actual process ID of the process you want to check. The output will list the process ID, memory usage in MB, and the command name.