Sign in to follow this  

[SOLVED]Strange memory leaks

This topic is 4023 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i've found some strange memory leaks:
bool CModel::OptimizeMesh(LPD3DXMESH *lpMesh){ 
	HRESULT hr = S_OK;

	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;

	SAFE_DELETE(pAdjacencyIn);

	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

etc...


Dave

Share this post


Link to post
Share on other sites

This topic is 4023 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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