Monday, October 15, 2012

Two level 400 Windows Store App troubleshooting tips, Diagnosing Memory Leaks & ProcDumping

All Your Base Are Belong To Us - Diagnosing Memory Leaks in Managed Windows Store Apps

There is so much material on the web (and even on this blog) about memory leak diagnostics in managed code, and a considerable number of tools that make diagnostics increasingly easier. Modern memory profilers can open application dumps, attach to live processes, display live memory graphs, compare snapshots, identify problematic retention patterns, and so much more.

Unfortunately, these tools presently don’t work with Windows Store apps. Moreover, the UI model of Windows Store apps poses a significant challenge in diagnosing many UI-related memory leaks, such as composite UI controls retaining objects embedded in them, or UI elements retaining objects registered to their events.

Namely, the Windows Store app UI framework is implemented in unmanaged code and exposed to C# apps through fairly standard COM interop (with some minor tweaks). Because the garbage collector has no insight into or control over unmanaged COM objects in the Windows Runtime, tracing a memory leak to its true source becomes exceptionally difficult. Needless to say, the lack of profiler support does not help – you need to pull the trusty WinDbg and SOS combination for even the simplest of problems.

To begin with, you can’t reliably keep WinDbg attached to a Windows Store app. It seems that Windows detects that the app is not running, and eventually terminates it under the nose of the debugger. This isn’t that big a deal – you have to resort to dump files instead. (On Windows 8, Task Manager can capture dumps for you; just make sure you capture dumps of 32-bit apps using the 32-bit Task Manager, and vice versa.)

...

image..."

Michael Crump - Using ProcDump to Monitor Windows 8 Store Apps

Introduction

There may be some instances where you want to monitor Windows 8 Store Apps without installing Visual Studio 2012. Thankfully you can do this pretty easily by using ProcDump and ProcessMonitor. Here is a step-by-step guide on how to do so or if you prefer, watch this video which inspired me to write this post.

...

image..."

I don't usually double-up posts like this (unless I'm doing a round-up or something... but anyway) yet I thought these two posts kind of, sort of related and complimentary so am making an exception...

No comments: