The Thread Viewer now features the tracking of the Stack Usage.
This feature is related to Zephyr's CONFIG_INIT_STACKS setting, which will set every byte in the threads' stack area to a special value. This creates a sort of high-level watermark, as the CPU will write other values to the part of the stack it's actually using, without cleaning up after itself. By looking for the first byte that is not the magic number, you can see how much of the stack your threads have been using at most. This is very useful for identifying threads that have too much or too little stack space allocated.
To improve this workflow, the Thread Viewer now analyzes the maximum stack usage for you. If you enable the CONFIG_INIT_STACKS setting, all new threads will be set up to track the maximum stack usage from the start. You can also press the new Enable Tracking button next to the Stack Usage header to paint the stack of all running threads.
You can inspect the maximum stack usage of each thread by hovering over the stack usage graph. We've also added a tiny marker to the stack usage bar to let you get an impression of the usage for each thread at a glance.
Note
The stack painting approach only works for the variables on the stack you're actually writing to. If you allocate a large array on the stack without initializing or writing to it, it will not affect the maximum stack usage.
If you want to read more about this approach to measuring the stack usage, read Noah Pendleton's recent post on Memfault's Interrupt blog, which inspired us to add this feature to the extension.