Game Development Community

Animation Memory Leak

by Juan Sanchez · in Torque Game Engine · 01/10/2008 (11:52 am) · 4 replies

We are using a heavily modified version of TGEA 1.0.2 and have encountered a massive memory problem revolving around character animations. Literally hundreds of MB are somehow loaded and leaked inside the TSShapeConstructor. It only happens with our higher-detail models (86 nodes in the skeleton). We have no problems with lower-detail models that have half that number, but load up the same animations (re-exported for the simplified skeleton of course).

We used several memory management tools and tracked down the problem to:
--tsShapeOldRead.cpp
----TSShape::importSequences(Stream * s)
------NodeRotations.setSize(sz+oldsz);
Seems to be trying to apply an offset based on the file version (which reads in as 24).

We currently have three leads we are pursuing to fix it:
1) TGEA Vector could be leaking like a sieve. It is appalling how over-used this data structure is in TGEA anyhow, and we have been toying with replacing it altogether.
2) Something is wrong with our models/skeletons. Maybe TGEA doesn't support something we are doing or we hit some invisible cap. We aren't doing anything fancy, so I doubt this is a problem.
3) Networking problem. We have disabled the networking code within TGEA and have long since fixed all associated problems. Still, the TGEA engine is extremely sloppy in some places (procedural programming forced into an object-oriented design) and maybe some ghost of it remains.

Anyhow, does anyone have any suggestions on where we should continue looking if those three don't produce results?

#1
01/10/2008 (12:44 pm)
Wouldn't it be simpler to post that to the TGEA boards instead of the TGE boards? ;-)
#2
01/10/2008 (12:54 pm)
I for one am glad it's posted here, as that same code is in TGE.

Juan, this is very interesting, please post anything you find around this!
#3
01/10/2008 (3:55 pm)
Are you sure it's leaking?

Which tools did you use?

I was able to use Visual Leak Detector on Windows and get our code base to zero leaks.

I don't think I fixed a leak in this area of the code.

That DSQ reading code DOES use a ton of memory though, and it's particularly inefficient (because it's taking a REALLY big vector, and incrementing by a small amount, and re-doing that a bazillion times). I rewrote it to behave a little better by trying to preflight both nodeRotations and nodeTranslations to the actual size necessary (using 'reserve').

If you are actually seeing a big leak here, I'd suggest that perhaps somehow your animations aren't getting cleaned up any more on quit? 'nodeRotations' is an embedded Vector, so it should get cleaned up when the TSShape does.
#4
01/11/2008 (9:39 am)
If this is the same issue I was experiencing, it was due to a bunch of memory being allocated and never deallocated. I disabled the memory manager and the "leak" went away.