I think I found a Havok Memory Leak

I think I found a Havok Memory Leak

Hi. We've been experiencing a memory leak in our game and I've been narrowing it down and I believe I have cornered it. It seems to be in havok though, and I'm not sure what steps I can do to resolve it.

We are using Havok 7.10r1.

We are using the hkMemoryInitUtil::initFreeList() function to create a memory router that we pass to hkBaseSystem::init.

The problem comes when we use the hkBinaryPackfileReader. If we remove the lastreference for it immediately after loading a file, the leak is not there, but when we keep the packfile in memory, and then load other packfiles, and then remove the last referenceto the packfiles the memory leaks.

I would be happy to provide any information you need to help resolve this.

Thanks in advance.

5 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

Hi,How are you testing for memory leaks? Could you try using hkMemoryInitUtil::initChecking in place of initFreeList? This will perform memory leak checks among other things. Chapter 8.1.2 on Memory Implementations in the docs discusses this further. Keep in mind that Havok holds on to memory with the FreeList allocator upon free. You can call garbageCollect on the FreeList allocator in order to release memory ( See Chapter 8 in the docs for more details.) Are you seeing the memory leak even after you call baseSystem::quit?Are you sure that you are not still referencing loaded data when the files are unloaded? Check that your PackfileData has a refcount of zero when you expect it to be cleaned up.Could you provide more details (sample code?) for your use case of loading a single file and loading multiple files?
Cheers,Tyler

Our packfiles do have a ref count of 0.

I'll try to get you some more information and I'll look over the docs. I'll try the initChecking thing as well. I'll also try the garbage collect function.

I'll let you know how it goes.

Thank you.

I'd like to try using the garbageCollect function on the free list allocator, but I can't seem to find a way to get to it in code.

We use initFreeList in hkMemoryInitUtil to create the hkMemoryRouter that we pass to hkBaseSystem::init.

I don't see a way to access the hkFreeListAllocator class from any of that.

I see that heap() returns an Allocator but that doesn't look like it's the same thing.
The diagram in chapter5 (Memory Overview) shows that the hkMemoryRouter's heap function initializes an hkMemoryAllocator.

I'm confused as to how to get from a hkMemoryRouter to the hkFreeListAllocator so I can use garbageCollect.

Any help would be appreciated. Thank you.

Sorry, I should have been more clear. You want to call garbage collect through the memory system, which will collect on the allocators.

hkMemorySystem & memory = hkMemorySystem::getInstance();
memory.garbageCollect();

You can find some samples on memory usage and reporting in the demos under:Demo/Demos/Physics/Api/Dynamics/MemoryIssues/Cheers,Tyler

Lascia un commento

Eseguire l'accesso per aggiungere un commento. Non siete membri? Iscriviti oggi