Diagnosing Native Memory Leaks with ETW and WPA

Tuesday, December 2, 2014

As a followup to my previous post on native memory leaks, here's a quick walkthrough for diagnosing memory leaks using Event Tracing for Windows. The process is fairly simple. The Windows heap manager is instrumented with ETW traces for each memory allocation and deallocation. If you capture those over a period of time (when your application is leaking memory), you can get a nice report of which blocks were allocated during the trace period and haven't been freed. If you also ask ETW to capture the call stack for allocation events, you can see where the application is allocating...
one comment

Native Memory Leak Diagnostics with Visual Studio 2015

Monday, December 1, 2014

The Current Landscape of Native Memory Diagnostics Leak diagnostics is a nasty business in native applications. There have been many attempts at solving this problem automatically. To name a few: The CRT Debug Heap (which is no longer used by default in Visual Studio 2015! - See update below.) can help identify memory leaks by associating each allocation with additional data on the allocating source file and line number. At program exit (or whenever a special CRT function is called), all blocks that haven't been freed are printed out. This has been around forever. The problem is that you need to...
8 comments

Garbage Collection and .NET Debugging at Build Stuff

Tuesday, November 25, 2014

I spent most of last week at Build Stuff, a really cool software conference in Vilnius, Lithuania. The conference was great with a really exciting atmosphere: energized, passionate developers having conversations and playing table tennis in the hallways during the day, and drinking lots of beer in the evenings. Even the weather was quite nice -- there was only a little snow, and temperatures didn't drop below -1 Celsius, which means we could walk around the old town's historical landmarks; grab some sushi, ribs, and beer; and do some window shopping. So, a great success! I was invited to deliver...
no comments

A Loop of Nested Exceptions

Monday, November 17, 2014

It was a pretty incredible coincidence. Only a few days apart, I had to tackle two problems that had to do with nested exception handlers. Specifically, an infinite loop of nested exceptions that led to a stack overflow. And that's a pretty fatal combination. A stack overflow is an extremely nasty error to debug; a nested exception means the exception handler encountered an exception, which can't be pretty; and to add insult to injury, a stack corruption was also involved behind the scenes. Read on to learn some more about the trickiness of diagnosing nested exceptions and what can...
4 comments

Making .NET Applications Faster: My Pluralsight Courses

Friday, November 14, 2014

I can't believe I waited until now to blog about it, but I have two courses on Pluralsight covering .NET performance optimization. If you've been reading this blog for any time now, you know this is one of my favorite topics -- and I was absolutely thrilled to join the Pluralsight author team in early 2014. My first course is titled Making .NET Applications Faster, and it was released in May. It's a fairly short course, running just under 2 hours, that covers the basics of .NET performance optimization. Some of my favorite topics include implementing value types correctly, using NGen...
8 comments

Why Lug a Laptop When an iPad Is More Than Enough

Tuesday, November 4, 2014

I don't go to conferences as an attendee as much as I used to, and that means I'm losing my organization skills at what to bring when I'm going to attend sessions all day. Theoretically, you need a laptop and a tablet and a phone and a bunch of cables and chargers and external battery packs and connectors and adapters -- how else could you survive a full day packed with sessions and do some urgent work to put out fires if necessary? Turns out, I can pretty much do everything I need on my iPad, if I'm willing...
tags: ,
no comments

TechEd Europe 2014: Mastering IntelliTrace in Development and Production

Monday, October 27, 2014

I'm flying to TechEd Europe tomorrow, and decided to run an experiment and post my slides and demos before the session. Why the weird timing? Well, after giving the schedule a cursory glance, there are so many great sessions! It's really hard to pick a session based on the short conference abstracts, and I wouldn't want anyone to come to my session if they aren't absolutely sure it's a topic they care about. My talk is titled Mastering IntelliTrace in Development and Production. I love IntelliTrace and use it a lot, but it still remains a fairly obscure Visual Studio...
2 comments

Talks from Software Architect 2014: Xamarin, Mobile Backends, and Swift

Friday, October 17, 2014

I'm sitting in the Lufthansa lounge at Heathrow Terminal 2 after another great conference in London. Software Architect (from the organizers of DevWeek) has just concluded, and I had the pleasure of delivering three talks on areas I am very excited about, all related to mobile application development. If you attended my talks, you'll find the following materials helpful; otherwise, stay tuned for the session videos that should be posted in a few weeks. Modern Backends for Mobile Apps Slides This session focused on Microsoft Azure Mobile Services and Facebook Parse, two strong competitors in the field of mobile app backends. Both...
no comments

DevConnections 2014: IntelliTrace, Diagnostics Hub, and .NET Production Debugging

Saturday, September 20, 2014

I'm flying back home from DevConnections 2014, which was great! Vegas was hot and dry as usual, but I actually managed to carve out some time in my schedule to see KA, which was really nice. (Plus, the conference was at the Aria resort, which is located smack in the middle of the strip, and is overall much nicer than Mandalay Bay where we were last year. I really liked the hotel room automation control. For example, I had an alarm clock set up to open the curtains, turn on the TV to a quiet music channel, and even...
no comments

Marshaling .NET and STL Collections in C++/CLI

Monday, August 25, 2014

When working with C++/CLI, you often have to convert C++ types to CLR types and vice versa. This most commonly happens with strings, but custom types and collections are just as painful. Visual C++ ships with a marshaling library in the msclr::interop namespace, which focuses on marshaling strings. However, it is notably lacking in the ability to marshal collections -- so you're left to your own devices if you have a std::map<std::string, std::vector<double>> that you need to mash into a .NET Dictionary<string, List<double>>. My wife and I spent a weekend writing a template library that marshals .NET and STL collections....
tags: ,
one comment