(Dx9 C++) Cannot find memory leak

Started by
7 comments, last by zyrolasting 15 years, 4 months ago
I triggered a breakpoint through the DX Control panel on a leak that I cannot identify. I know I'm releasing everything properly. The leak happens at the __crtExitProcess(code); call when I close the app under crt0dat.c, (and I have no idea what that is). I have no idea what to make of it. Does anyone know if a common leak has something to do with this line of code?
Advertisement
im pretty certain that if dx tells you there is a leak that you are missing something.

without being able to step through the code i cant be much help though
http://stowelly.co.uk/
This very much looks like a forgotten release call to one of the DX COM interfaces. I remember having similar problems, from time to time, and finding the missing release calls was a painfull task.

Now I assign all all my COM interfaces to std::tr1::shared_ptr< IWhateverInterface > using a custom deallocator ReleaseCOMPtr().

By doing so you get the additional benefit, that you can see the number of references you hold to the resource from within the debugger, by inspecting to shared pointers reference count.

EDIT: In this thread I described my approach in more detail...

Best Jochen

[Edited by - jochen on November 28, 2008 5:17:04 AM]
Why did Doug Gregor create the empty directory?
I use CComPtr from atlbase.h. You can use the CRT to break on an allocation ID to show you where it came from. D3D should allow this also and tell you the number.
I'll take your guys word for it and look again.
I did use an AllocID, but it broke at a call to EndScene() for my device.

I don't know how a leak could be there, but I did head on back to check the
counts of my Direct3D main interface, device and sprite pointers. Nothing seems to be amiss there, but that's where the breakpoint remains.

I'm writing my own function to check my ref counts now. If I don't find the problem THERE, I'll post again.

jochen: Thanks for the code offer, but I do not understand it yet; the sample had several features out of my league. I'd like to understand what I'm using before using it. I'll keep it in mind, though.
Quote:
jochen: Thanks for the code offer, but I do not understand it yet; the sample had several features out of my league. I'd like to understand what I'm using before using it. I'll keep it in mind, though.



I think there should not be 'out of my league' code. If so, it's either hard to understand or badly documented. My bad, sry. I'll take that as gentle reminder to improve it.
Why did Doug Gregor create the empty directory?
Quote:
I think there should not be 'out of my league' code. If so, it's either hard to understand or badly documented. My bad, sry. I'll take that as gentle reminder to improve it.


Nonono, it's more that I don't understand the fundamentals, let alone some keywords in your code. I'm sure your stuff is fine, (the purpose sounds good, even) I just don't have the experience to know *exactly* what your code was doing.

Anyway, I have an update. I cleared out the majority of my memory leaks, but I still have a small one in my model class, but I don't know what it is.

I'm using a typical deallocating function for it.

void CIsoDev_3D_Model::FreeModel(){	if (Material) delete[] Material;	for (DWORD i = 0; i < numMaterials; i++)	{		Texture->Release();	}	if (Texture) delete[] Texture;	Mesh->Release();}


After commenting code for my models out, my memory leaks vanish.
Aren't I deleting everything a mesh needs to be freed? What am I forgetting?

[Edited by - zyrolasting on November 28, 2008 7:48:32 AM]
Your code should've looked like this:

void CIsoDev_3D_Model::FreeModel(){	if (Material) delete[] Material;	if (Texture) {		for (DWORD i = 0; i < numMaterials; i++)		{			Texture->Release();		}		delete[] Texture;	}		if (Mesh) Mesh->Release();}


I doubt that'll solve the problem, however.
Got it, thanks.

I still cannot find the leak, true. I could find it myself, but I am at a loss for an appropriate method. Since the App triggers no breakpoint on it's own anymore (I should have mentioned this earlier, the leak is reported after MemFini! and the closing of the window thread in my Output window.)

I also do not know how to best interpret CRT dumps. I've done more research on google, but I'm still at a loss; I'm not really finding anything.

This topic is closed to new replies.

Advertisement