Jump to content
  • Advertisement
Sign in to follow this  
khulad

DirectX 9.0c Memory Leak

This topic is 2713 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

Hi guys,
I've found what's causing my memory leak (3 allocations not released), if I comment out the line I get no leaks.
The offending line is:

HR(D3DXCleanMesh(D3DXCLEAN_SIMPLIFICATION, mMeshShip, adjaceny, &mMeshShip, outAdjaceny, &buffErr));


The surrounding code is this:


DWORD* adjaceny = NULL;
adjaceny = new DWORD[3 * mMeshShip->GetNumFaces() * sizeof(DWORD)];
DWORD* outAdjaceny = NULL;
outAdjaceny = new DWORD[3 * mMeshShip->GetNumFaces() * sizeof(DWORD)];

HR(mMeshShip->GenerateAdjacency(EPSILON, adjaceny));
// Clean the mesh because we'll be performing simplifications
LPD3DXBUFFER buffErr = NULL;
HR(D3DXCleanMesh(D3DXCLEAN_SIMPLIFICATION, mMeshShip, adjaceny, &mMeshShip, outAdjaceny, &buffErr));


Just so you know mMeshShio is a valid mesh.
Any ideas? I've tried placing memory breakpoints on the allocID DirectX suggests (from the debug outpout window) but it never breaks. Like I said if I comment the offending line out I don't get any memory leaks.

Share this post


Link to post
Share on other sites
Advertisement
According to the documentation it seems the function creates a new mesh, so you can't just use &mMeshShip to get the output, you must use a separate variable, and then release the old one and replace it with the new one. Also, do you release buffErr if it's non-NULL?

Share this post


Link to post
Share on other sites
Yes I do release buffErr if it isn't non-Null. I can't believe I missed that part of the documentation. I'll make the ammendments now and let you know.
Thankyou.

Share this post


Link to post
Share on other sites
Yep, you was right. :)

This code worked:

ID3DXMesh* temp = NULL;
HR(D3DXCleanMesh(D3DXCLEAN_SIMPLIFICATION, mMeshShip, adjaceny, &temp, outAdjaceny, &buffErr));
ReleaseCOM(mMeshShip);
mMeshShip = temp;
temp = NULL;


I must learn how to read documentation properly. :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!