A while back I wrote a great (and perhaps somewhat ugly) batch file that does it, it requires gnuwin32's sed and cut.
I wrote it 'cos I was horrified how much RAM modern browsers take up and I wanted to see quickly.
I am currently trying to neaten it up but this is it as it is.
So, it's saying that Chrome is using 3.4GB
C:\>ramchrome<ENTER>
>=1GB
3GB
3,480,288
3.4GB (rounded down)
3480288KB
Here is the batch file. At one time it was much simpler. But I wanted to add e.g. GB and KB .. and that takes up most of the batch file. It's very future proof because even if Chrome took up a bunch of yottabytes (a yottabyte is million trillion megabytes) then my batch should or at least, is written, to support that.
The basis of how the internals of the batch file works is simple.. It creates some temp files.. which you can look at.. You see it basically outputs a list of all the processes, filters out the ones for chrome.exe grabs just the part that states how many bytes it uses. Then the last temp file you can output you see it just has a list of all the bytes used by each chrome.exe process, with any commas or spaces removed, and then a for statement sums them all. The last temp file could be opened in excel.. though there isn't a need to.
You see how to use the bat file, just run it and see what it outputs. You don't need to know how it works, but that's how it works. You see from looking at the temp files it generates.
@echo off
setlocal enableextensions enabledelayedexpansion
set tempfile1=%temp%\asdf1.a
set tempfile2=%temp%\asdf2.a
set tempfile3=%temp%\asdf3.a
set tempfile4=%temp%\asdf4.xls
tasklist >%tempfile1%
type %tempfile1% | grep "chrome" > %tempfile2%
cut -b 68- %tempfile2% > %tempfile3%
sed -r "s/\d32|K|,//g" %tempfile3% >%tempfile4%
set total=0
for /f %%f in (%tempfile4%) do @(set /a total+=%%f)>nul
:: --- added this
set a=%total%
if "%a:~-9,-6%"=="" echo ^< 1GB
if NOT "%a:~-13,-6%"=="" echo ^>=1GB
set yotta=%a:~-24,-21%
set zetta=%a:~-21,-18%
set exa=%a:~-18,-15%
set peta=%a:~-15,-12%
set tera=%a:~-12,-9%
set giga=%a:~-9,-6%
set mega=%a:~-6,-3%
set kilo=%a:~-3%
set prefix=
if NOT "!yotta!"=="" (
set yotta=!yotta!,
if "!prefix!"=="" (
set prefix=YB
echo !a:~-24,-21!!prefix!
)
)
if NOT "!zetta!"=="" (
set zetta=!zetta!,
if "!prefix!"=="" (
set prefix=ZB
echo !a:~-21,-18!!prefix!
)
)
if NOT "!exa!"=="" (
set exa=!exa!,
if "!prefix!"=="" (
set prefix=EB
echo !a:~-18,-15!!prefix!
)
)
if NOT "!peta!"=="" (
set peta=!peta!,
if "!prefix!"=="" (
set prefix=PB
echo !a:~-15,-12!!prefix!
)
)
if NOT "!tera!"=="" (
set tera=!tera!,
if "!prefix!"=="" (
set prefix=TB
echo !a:~-12,-9!!prefix!
)
)
if NOT "!giga!"=="" (
set giga=!giga!,
if "!prefix!"=="" (
set prefix=GB
echo !a:~-9,-6!!prefix!
)
)
if NOT "!mega!"=="" (
set mega=!mega!,
if "!prefix!"=="" (
set prefix=MB
echo !a:~-6,-3!!prefix!
)
)
if "!mega!"=="" (
if "!prefix!"=="" (
set prefix=KB
echo !kilo!
)
)
echo !yotta!!zetta!!exa!!peta!!tera!!giga!!mega!!kilo!
if "%prefix%"=="YB" echo !a:~-24,-21!.!a:~-21!YB (rounded down)
if "%prefix%"=="TB" echo !a:~-12,-9!.!a:~-9,1!TB (rounded down)
if "%prefix%"=="GB" echo !a:~-9,-6!.!a:~-6,1!GB (rounded down)
if "%prefix%"=="MB" echo !a:~-6,-3!.!a:~-3,1!MB (rounded down)
:: echo %a:~-13,-6%,%a:~-6,-3%,%a:~-3%
set a=
:: -----------
echo %total%KB
set tempfile1=
set tempfile2=
set tempfile3=
set tempfile4=
To summarize how it works, here is a sample of the first temp file asdf1.a as you can see it lists many processes not just chrome.exe
chrome.exe 5572 Console 1 64,784 K
chrome.exe 3880 Console 1 155,376 K
chrome.exe 14516 Console 1 106,932 K
chrome.exe 2524 Console 1 88,464 K
dllhost.exe 15996 Console 1 8,844 K
tasklist.exe 16232 Console 1 7,152 K
The second temp file gets closer to what we want, by filtering out chrome.exe
asdf2.a
chrome.exe 5572 Console 1 64,784 K
chrome.exe 3880 Console 1 155,376 K
chrome.exe 14516 Console 1 106,932 K
chrome.exe 2524 Console 1 88,464 K
asdf3.a gets closer still
64,784 K
155,376 K
106,932 K
88,464 K
asdf4.xml (don't ask why it's .xls maybe I intended to open it in excel)
64796
155592
114084
88464
So then you the batch file has generated a plain list to sum.
and obviously this line of the batch file does the summing
for /f %%f in (%tempfile4%) do @(set /a total+=%%f)>nul
Note Using a batch file to write this was silly.. Batch files are often not very portable because a slight change in the output of a command with a new version of the OS or a new version of a command, can make the program not work. And if it relies on third party programs where different versions of them are out there then it's not good. And many of gnuwin32's commands are out of date, cygwin tends to be more up to date with its versions of commands. This was running fine for me though now I tried it it gave an error.
I might write something in C# instead at some point.
Also note that as Rick pointed out, this doesn't take into account DLLs used by a program. Though personally I find what is useful to me is to know how much is used by the executable (or in the case of some modern browsers, the many instances of the executable!)