Skip to main content
GameDev.net gamedev.net
🔒 Locked

Dramatic memory leak in DrawText

Started by TiLT Jan 31, 2006 at 3:41 PM 5 replies 2.1k views
Original Post
TiLT
TiLT
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.
Mike.Popoloski
Mike.Popoloski
Try the fluid studios memory manager. Its great, free, and could probably help you find your problem. It will print a report of all memory leaks in your program, as well as a report of every allocation, reallocation, and deallocation. And you won't even have to change much of your code, just include the headers and the source file. www.fluidstudios.com/pub/FluidStudios/MemoryManagers/Fluid_Studios_Memory_Manager.zip
Mike Popoloski | Journal | SlimDX
sirob
sirob
Seems to like neither would really help, since it does get released when the app closes.

Have you tried E-mailing the DX team? If the problem also occurs in their sample, they'll want to know about it, and might give you a solution/fix it.

I'm not too sure what their E-mail is, but I'm sure someone here would be happy to post it.
Sirob Yes.» - status: Work-O-Rama.
Steven Hansen
Steven Hansen
You might try searching the following forum. It is generally for industry professionals, and they don't welcome casual banter, but there is a good bit of core information there. Plus, the actual DirectX development team participates on the forum.

DirectXDev
TiLT
TiLT
Thanks, I'll try getting in touch with MS about this. I also posted this thread on the MSDN forums, and two people were able to reproduce the problem, so it's not an isolated case.
TiLT
TiLT
Just wanted to say that this has been verified and submitted to the DirectX team as a bug. Hopefully it'll get fixed in the April release of the SDK.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.