Hi, I have a bit of a 2 part question. First, the memory leaks.
Here is an example of the output I get from checking memory:
Memory Leaked (4 times with this stack):
Address=0x110A4010 size=74 flags='Heap' thread=1736 time=0.39
y:\build\20120405_200003_pcxsperpetualkeycode\source\common\base\system\stacktracer\impl\hkstacktracerwin32.cxx(229):'hkStackTracer::getStackTrace'
y:\build\20120405_200003_pcxsperpetualkeycode\source\common\base\memory\system\checking\hkcheckingmemorysystem.cpp(678):'hkCheckingMemorySystem::checkedAlloc'
y:\build\20120405_200003_pcxsperpetualkeycode\source\common\base\memory\system\checking\hkcheckingmemorysystem.cpp(51):'hkCheckingMemorySystem::AllocatorForwarder::bufAlloc'
y:\build\20120405_200003_pcxsperpetualkeycode\source\common\serialize\data\util\hkdataobjecttonative.cpp(161):'hkDataObjectToNative::copyIntoNativeArray'
y:\build\20120405_200003_pcxsperpetualkeycode\source\common\serialize\data\util\hkdataobjecttonative.cpp(962):'hkDataObjectToNative::fillNativeMembers'
y:\build\20120405_200003_pcxsperpetualkeycode\source\common\serialize\data\util\hkdataobjectutil.cpp(366):'Copier::deepCopyToNative'
y:\build\20120405_200003_pcxsperpetualkeycode\source\common\serialize\data\util\hkdataobjectutil.cpp(399):'Copier::toObject'
y:\build\20120405_200003_pcxsperpetualkeycode\source\common\serialize\data\util\hkdataobjectutil.cpp(453):'hkDataObjectUtil::toObjectWithRegistry'
y:\build\20120405_200003_pcxsperpetualkeycode\source\common\serialize\util\hkserializeutil.cpp(513):'hkSerializeUtil::loadOnHeap'
y:\build\20120405_200003_pcxsperpetualkeycode\source\common\serialize\util\hkserializeutil.cpp(542):'hkSerializeUtil::loadOnHeap'
Below this in the output are parts of my code that lead to the memory leak. I have
hkObjectResource *loadedAnimation = hkSerializeUtil::loadOnHeap( animSkelPath.c_str() );
hkRootLevelContainer *animationContainer = loadedAnimation->stealContents<hkRootLevelContainer>();
delete loadedAnimation;
hkaAnimationContainer *ac =(hkaAnimationContainer*)( animationContainer->findObjectByType(
hkaAnimationContainerClass.getName() ) );
hkaSkeleton *skeleton = NULL;
if( ac->m_skeletons.getSize() != 1 )
{
std::cout << ac->m_skeletons.getSize() << " skeletons found!---------------------" << std::endl;
m_animatedSkeleton = NULL;
}
else
{
skeleton = ac->m_skeletons[0];
m_animatedSkeleton = new hkaAnimatedSkeleton( skeleton );
skeleton->addReference();
}
delete animationContainer;
as the code which is causing the memory leak. I'm not sure what I'm doing wrong, really. When I'm shutting down my application, I am 100 percent sure that m_animatedSkeleton has its reference count reduced to zero. I am leaking memory from all of the places in my code that I load from files, so I assume it must be something wrong with my syntax there. I will put the second question in a comment to make it easier to tell between them.
EDIT: I seem to have found the solution. Removing all references on an animatedSkeleton will not remove references on its related binding. However, removing reference on the binding will remove reference of the animatedSkeleton. I'm not sure how why this is.


