Debugging - Finding a native heap leak with WinDbg

While writing the MySQL .NET UDF Plugin I had to break away from my daily use of .NET. I have done a bit with Win32 COM before but not enough to know all of the ins and outs. But, as I plow through some books and bad code examples I introduce all kinds of bugs. Most notably memory leaks. I will show what leaks I found and how I fixed them using a couple of WinDbg commands as well as a few utilities.

MySQL .NET Hosting Extension - Part 9 - Strings, _bstr_t, SafeArrays, SysAllocString, SysFreeString

Up until now I’ve been dealing with integers and reals. This is great for a lot of statistical information but we all know that databases are used for more than just storing numbers. Depending on your type of database you will most likely have a number of text items that are used to describe or othewise identify some integer value. In order to work with these values we have to marshal the data to and fro. Let’s dive in to what’s happening.

MySQL .NET Hosting Extension - Part 8 - Mimicking IIS (Shadow Copy, Custom Configs)

One of the coolest things about deploying to IIS is the shadow copy feature. This allows you to drop in a new DLL and when the application detects it, it will spin up a new AppDomain and send all new requests there. This “seamless” integration is great for achieving high availability. Web servers and SQL servers alike need to experience as little down time as possible. We will walk through adding shadow copy and implementing file watchers inside of the MySQLHostManager that will handle these conditions.

MySQL .NET Hosting Extension - Part 7 - AppDomain Pools

If we look at some of the performance metrics of the MySQL UDF extension, we’re not looking great for a few items. Number one, of course, is the loading of the .NET CLR. Unfortunately unless I integrate this tool into the MySQL code itself I can’t control that. The next is the loading and use of the AppDomain. That, however, I can fix.

Y U NO HAVE BUTTON?

Seriously, it’s 2014 almost 2015. I wanted to add a file type association to my machine using the provided Windows interfaces. I added an association by using the open file dialog, but realized after the fact that I wanted to give the file type a better name. A quick Google search provided a number of links asking how, but only one that told me how.