About less than an hour ago I got an idea, because my laptop with 5.6 GB of usable memory kept popping up a message telling me to close programs xyz – I’m sure you know it too. So I decided to write a small program that would tell me which programs take up the most memory. Maybe one day I’d like to show off to someone how much memory each program uses on my machine. In the Process class I found these properties, but not a single one of them told me what the Task Manager in Windows showed:
long nonpagedSystemMemorySize = item.NonpagedSystemMemorySize64;
long pagedMemorySize = item.PagedMemorySize64;
long pagedSystemMemorySize = item.PagedSystemMemorySize64;
long peakPagedMemorySize = item.PeakPagedMemorySize64;
long peakVirtualMemorySize = item.PeakVirtualMemorySize64;
long privateMemorySize = item.PrivateMemorySize64;
long virtualMemorySize = item.VirtualMemorySize64;
long workingSet = item.WorkingSet64;Of course, all of these methods were also available without the “64“, but as I expected, it just wasn’t it. After going through about 30 pages, I finally came across this article on CodeProject: http://web.archive.org/web/20250821023102/https://www.codeproject.com/Articles/38438/Monitoring-Process-Statistics-in-C-WPF . I found the code I needed, and it was actually simple – just 2 lines: the first created an instance of System.Diagnostics.PerformanceCounter and the second read the value from that object.
I copied it into my own program, put the results into a dictionary and so on (now it occurs to me whether it wouldn’t have been easier to put them into a collection and call Sort(IComparer) on it), and in the end I got this (just a note: where a process has no .exe, it is a 64-bit process whose exe name I couldn’t get via the Process.MainModule.FileName property, so the text from Process.ProcessName is shown instead):
- Idle – 24
- System – 148
RockMeltCrashHandler.exe– 344- smss – 368
- WLIDSVCM – 992
- SynTPHelper – 1016
chrome_frame_helper.exe– 1052- wininit – 1084
- atiesrxx – 1140
sqlbrowser.exe– 1160Wakoopa.exe– 1360- Fuel.Service – 1448
- sqlwriter – 1476
AppleMobileDeviceService.exe– 1560mDNSResponder.exe– 1624- AdminService – 1632
RIconMan.exe– 1648Ath_CoexAgent.exe– 1652- lsm – 1680
- wlanext – 1704
- atieclxx – 1748
- fdlauncher – 1856
- dllhost – 1880
- winlogon – 2172
GoogleUpdate.exe– 2460- SearchProtocolHost – 2464
- notepad – 2648
- conhost – 2736
- SearchFilterHost – 2776
- WLIDSVC – 2788
- taskmgr – 2820
ScrybeUpdater.exe– 3320- fdhost – 3616
NahradDiakritikuVeTrayi.exe– 3676- csrss – 3964
- SynTPEnh – 4188
- taskhost – 4744
- TCMDX64 – 4844
- ZalohaSrc.vshost – 5012
- MsDepSvc – 5308
- spoolsv – 5420
- BtvStack – 5844
- lsass – 5852
- services – 6108
- MemoryPerformanceMonitoring.vshost – 6188
- nlsvc – 6724
- wmpnetwk – 8548
TeamViewer_Service.exe– 8816- NLClientApp – 8956
- TOTALCMD.EXE – 9548
- msvsmon – 9984
test.vshost.exe– 10964- audiodg – 11428
AddInProcess32.exe– 12760scrybe.exe– 12944- dwm – 23056
googletalk.exe– 28444- ReportingServicesService – 29904
FluffyApp.exe– 31496vlc.exe– 31808- SearchIndexer – 38760
twhirl.exe– 54172- svchost – 69920
- explorer – 70224
- sqlservr – 91424
Skype.exe– 123868- MetroTwit – 132136
VCSExpress.exe– 260432chrome.exe– 775852
PS: For some reason, only tasks running under the logged-in account (.sunamo) are listed here, but this is the very first version of the program, so it doesn’t matter all that much.