Jump to content
  • Advertisement
Sign in to follow this  
fuchiefck

Memory leak problem

This topic is 4813 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, has anyone encountered situations where your program causes memory leaks only with some certain .x files, while some others won't? I am building a program on MFC, basically loading a mesh hierarchy for animations. thanks very much in advance... EDIT: most of the leaked data contains the names of the Frames in the hierarchy... -fuchiefck

Share this post


Link to post
Share on other sites
Advertisement
Umm, I think I have isolated the problem... It only causes memory leaks with xfiles containing more than one animation set, eg the tiny_4anim.x from the MultiAnimation sample.

Would anyone be able to help me out...?

thanks..

-fuchiefck

Share this post


Link to post
Share on other sites
Have you run it against the debug runtime (maximum output) and reference device? any chance you could tell us if/what is reported?

What implementation are you using? stock D3DX stuff, or your own code?

I haven't dealt with animations in ages (don't have an artist to make them for me [sad]) but are you sure that the implementation you're using (see prev. Q) supports multiple animation sets?

hth
Jack

Share this post


Link to post
Share on other sites
Finally I have solved the problem, Its a small problem that took me around 3 days to solve... (just like a lot of other problems..!)

Anyway I discovered that the problem lied with the AnimationSet pointers. My Program (MFC) loads up a mesh and it grabs all the animation sets and puts it into a ComboBox for selection.

Originally this part of the code looked like:


m_ComboBox1.ResetContent();
if (m_pAnimController)
{
LPD3DXANIMATIONSET animset = NULL;
//add animations to combobox selector
for (int i = 0; i < (int)m_pAnimController()->GetNumAnimationSets(); i++)
{

m_pAnimController->GetAnimationSet(i, &animset);
LPCSTR AnimationName = animset->GetName();
if (AnimationName)
m_ComboBox1.AddString(AnimationName);
else
m_ComboBox1.AddString("unnamed");


}
SAFE_RELEASE(animset);
}


But I found out that it was the animset that was not getting released properly, so I declared the animset pointer within the for loop and released it at the end of every loop, to make sure I am only working with one pointer at once, and they don't get their reference counter incremented all the time (I think that's what happened, according to my very shallow knowledge of COM)... now its perfect....... so far... i hope.

SOLUTION:


m_ComboBox1.ResetContent();
if (m_pAnimController)
{
//add animations to combobox selector
for (int i = 0; i < (int)m_pAnimController()->GetNumAnimationSets(); i++)
{
LPD3DXANIMATIONSET animset = NULL;
m_pAnimController->GetAnimationSet(i, &animset);
LPCSTR AnimationName = animset->GetName();
if (AnimationName)
m_ComboBox1.AddString(AnimationName);
else
m_ComboBox1.AddString("unnamed");

SAFE_RELEASE(animset);
}
}


Anyway just a little precaution that may help, if anyone tries to do something similar.

thanks jollyjeffers and matthughson for providing the suggestions... which gave me things to think about

-fuchiefck

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!