Original Post
I've rigged up a program and using the DX debugger I have as far as I can see removed all the memory leaks. The Debug output shows memfini with no mention of memory leaks. Until that is when I added an effects class to handle effect files and their use in my primitive class. It is now throwing out the following message: Direct3D9: (INFO) :MemFini! Direct3D9: (WARN) :Memory still allocated! Alloc count = 508 The number changes the longer the program runs of course but I can't seem to find out where the leak is. I have a release function that releases, deletes and/or nulls any variables it uses but it still has something there. Now, after reading the forums I stumbled across a post that pointed out some CRT functions so started with : _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF); in my main function and it trapped almost 1000 of these apparent memory leaks. I then used : _CrtSetBreakAlloc(44); To break on the first apparent memory leak. Which happened to be my first line of code *sigh*. CDXEngine* lEngine = new CDXEngine(); Why would it think that was a memory leak. Thats simply the engine class being initialised. I tried a few more and so far only lines of code using 'new' are being tracked. Where are the memory leaks ? How can I find out memory leaks inside a single class where I think the problems are ? Why the heck couldn't they give you line numbers or source files to give you a head start :D Thanks for reading this garbled message. And thanks in advance for any ideas. edit: This seems to be the block of code at fault. In that format no memory leaks appear (using just the dx debugger). But simply by un remming the CreateFromFile line I get the memory leaks. This is all that routine does. I can't see anything wrong with it. All the class m_ variables are initialised to 0 or in the case of the device and filename the values passed when the class was initialised. Unless it is a problem with DX itself *laughs*. [Edited by - Xrystal on November 14, 2006 7:36:57 PM]
if (m_bHasEffects)
{
//if (!m_pEffect->CreateFromFile()) return false;
//m_pEffect->UseTechnique();
//int passes = m_pEffect->Begin();
//for (int i = 0; i < passes; i++)
//{
// m_pEffect->SetConstants();
// m_pEffect->BeginPass(i);
if (m_bHasIndices) hr = m_pD3DDevice->DrawIndexedPrimitive(type,0,0,m_iCount,0,count);
if (!m_bHasIndices) hr = m_pD3DDevice->DrawPrimitive(type,0,count);
if (hr == D3DERR_INVALIDCALL)
{
MessageBox(NULL,"Invalid Call","Drawing Primitive",MB_OK);
return false;
}
// m_pEffect->EndPass();
//}
//m_pEffect->End();
}
HRESULT hr = D3DXCreateEffectFromFile(m_pD3DDevice,m_szFileName,
m_pD3DDefines,m_pD3DInclude,
m_dwShaderFlags,m_pD3DPool,
&m_pD3DEffect,&m_pD3DCompileErrors);
if (hr == D3D_OK)
{
m_bCreated = true;
return true;
}
if (hr == D3DERR_INVALIDCALL)
{
MessageBox(NULL,"Invalid Call","Create Effect from File",MB_OK);
return false;
}
if (hr == D3DXERR_INVALIDDATA)
{
MessageBox(NULL,"Invalid Data","Create Effect from File",MB_OK);
return false;
}
if (hr == E_OUTOFMEMORY)
{
MessageBox(NULL,"Out of Memory","Create Effect from File",MB_OK);
return false;
}
if (!m_pD3DEffect) return false;