Original Post
I've been banging my head against the wall for the last few days trying to track down the source of a rather big memory leak in my Direct3D-application. Turns out the culprit seems to be the DrawText function. Let me explain exactly what happens: I'm using a variable width truetype font (Times New Roman) created through D3DXCreateFont. I'm using this in various parts of my application, but the part where the problems are easiest to notice is in my custom UI textboxes. I use a function called InsertText to add new characters to the printed string, and everything I initialize is cleaned up properly afterwards. The problems only truly begin upon typing the "f" or the "j" character, and only if they are lowercase. I assume it has something to do with them overlapping other characters. Every time a new character is added to the string after an f or a j has already been added, the application's memory footprint increases by a minimum of 300k, and in some cases can expand by over a MB. When the application exits, all of this memory is freed properly, leaving no leaks. As you can probably imagine, even just entering a line of chat in a chatbox could drain the computer of about 50 megs of RAM which won't be freed until the application exits. I've tested this on three different computers. Two are nearly identical, and the problem appears on both. The third computer is older, but doesn't suffer from this issue. Is this a known issue, or did I do something wrong? What can I do to fix it, apart from using fixed-width fonts (which don't suffer from this)? I'd *really* appreciate any help I can get with this. This issue also appears in the CustomUI sample included with the DirectX SDK. I'm using the December 2005 update.