Windows exposes a few more metrics in its api than is available to see in Task Manager. ZBiggestProcess shows some of the metrics of the highest memory commited process and displays it as an overlay on screen.
NtQuerySystemInformation
with the SystemProcessInformation
flag is the heart of this project. The metrics from this method is what the overlay uses to display. Using this method was not as straight forward as I thought, as it returns an array of packed SYSTEM_PROCESS_INFORMATION
elements that need to be travered. Each element is packed in memory and can be a different size, so NextEntryOffset
needs to be looked at for every element. Once that is all handled getting access to the metrics is very straight forward. All up the project is less than 100 lines of C code.
Findings
- Not a surprise really, but for my system electron apps and web browsers generally use the most memory. At times certain programs (like the 10x editor) can use more but drop back down.
- Certain apps allocate and deallocate way more often than I realized. I found the Discord desktop app to allocate and deallocate many times for every mouse motion (this is more than suspicious).
- This was my first project with the 10x editor and I'm liking it more and more every day. A great program.
- Some windows internal processes consume a huge amount of memory at times. A process called
Memory Compression
had the highest peak memory usage at times with a few gigabytes committed. - Blting straight to the screen is quite easy and nice in Windows if in a rush. Bypassing all the logic for window handling allowed me to produce something in the very little time I had for this jam.
- Jams are fun even for small projects :)
Possible updates
- Add more of a UI for the overlay and add controls in the system tray. Originally planned for the jam but scrapped due to time.
- Add more real time visualizations for memory usage, would be nice to graph eggregious apps like the Discord Desktop app in terms of memory allocations.