user13
user13

Reputation: 391

Memory usage per process

How can one see the output of the memory usage per process in Windows using bash (Git bash) and without any additional tools installation?

I read about top command but there is no such thing in the default version of bash. Also, I have read about ps but it does not give the memory usage at all as in some examples I have seen (maybe some version has been changed).

Upvotes: 1

Views: 1586

Answers (1)

Maxim Egorushkin
Maxim Egorushkin

Reputation: 136505

Since Linux processes in WSL run in a container (conceptually similar to Docker), they can only see processes in the same container, nothing else.

You can see the virtual and resident size of processes in WSL by issuing the following command:

ps -eHww -o uid,pid,ppid,psr,vsz,rss,stime,time,cmd

Outputs:

max@supernova:~$ uname -a
Linux supernova 4.4.0-17763-Microsoft #379-Microsoft Wed Mar 06 19:16:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux
max@supernova:~$ ps -eHww -o uid,pid,ppid,psr,vsz,rss,stime,time,cmd
  UID   PID  PPID PSR    VSZ   RSS STIME     TIME CMD
    0     1     0   0   8324   156 23:36 00:00:00 /init
    0     3     1   0   8328   156 23:36 00:00:00   /init
 1000     4     3   0  16796  3424 23:36 00:00:00     -bash
 1000    35     4   0  17084  1716 23:57 00:00:00       ps -eHww -o uid,pid,ppid,psr,vsz,rss,stime,time,cmd

Upvotes: 2

Related Questions