Sign in to follow this  

[SOLVED]Strange memory leaks

Recommended Posts

i've found some strange memory leaks:
bool CModel::OptimizeMesh(LPD3DXMESH *lpMesh){ 

	DWORD *pAdjacencyIn = NULL;
	LPD3DXMESH tMesh = *lpMesh;
	pAdjacencyIn = new DWORD[tMesh->GetNumFaces()*sizeof(DWORD)*3];

	hr = tMesh->GenerateAdjacency(1e-6f, pAdjacencyIn); 
	if( FAILED(hr) )
		return false;

	hr = D3DXCleanMesh( D3DXCLEAN_SIMPLIFICATION  , tMesh, pAdjacencyIn, &tMesh, pAdjacencyIn, NULL);
	if( FAILED(hr) )
		return false;


	return true;

if i comment out D3DXCleanMesh, there are no leaks. This is the output at the end of the program: The thread 'Win32 Thread' (0xa4) has exited with code 0 (0x0). D3DX: MEMORY LEAKS DETECTED: 2 allocations unfreed (5436 bytes) Any advices? [Edited by - b3rs3rk on December 12, 2006 8:17:54 AM]

Share this post

Link to post
Share on other sites
I would suggest wrapping all of the COM interfaces you use from DirectX in a com pointer. CComPtr will manage the reference counting of the interfaces automagically.

#include <atlbase.h>

CComPtr<IDirect3DVertexBuffer9> Direct3DVertexBuffer



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this