How to find user memory usage in linux

How to find user memory usage in linux

Finding out who/what is using the most memory is vital when trying to figure out is causing your system to run out of memory.

There are many ways to figure out what is using the most memory.

1) Find out what is using the most memory

for USER in $(ps haux | awk '{print $1}' | sort -u); do ps haux | awk -v user=$USER '$1 ~ user { sum += $4} END { print user, sum; }' ; done

2) Find out what is using the most memory in percent

TOTAL=$(free | awk '/Mem:/ { print $2 }'); for USER in $(ps haux | awk '{print $1}' | sort -u); do ps hux -U $USER | awk -v user=$USER -v total=$TOTAL '{ sum += $6 } END { printf "%s %.2f\n", user, sum / total * 100; }'; done

3) If your system supports, try to install and use smem:

smem -u
User     Count     Swap      USS      PSS      RSS 
gdm          1        0      308      323      820 
nobody       1        0      912      932     2240 
root        76        0   969016  1010829  1347768 

or

smem -u -t -k
User     Count     Swap      USS      PSS      RSS 
gdm          1        0   308.0K   323.0K   820.0K 
nobody       1        0   892.0K   912.0K     2.2M 
root        76        0   937.6M   978.5M     1.3G 
ameskaas    46        0     1.2G     1.2G     1.5G
 
 
 
 
  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

Setup logrotate to rotate your logs

Use logrotate to Manage Log Fiiles logrotate is a tool for managing log files created by...

CentOS One Liner Commands

Centos Oneliners kill all pts for x in $(ps aux | grep pts| awk '{print $2}'); do kill...

Expand your bash history to 2500

Expand your .bash_history to 2500 I do alot of testing and alot of work on Centos servers. I...

Install PHP/PHP-FPM 5.4 Centos 7

Install PHP/PHP-FPM 5.4 on Centos 7 PHP is a server-side scripting language designed for web...

Setup vsftp with SELinux

Howto Setup vsftp with SELinux Vsftpd is a fast and secure FTP server. Installing an FTP...