Ucenna

So I'm attempting to implement object pooling in my game engine, as spine asset construction is one of the biggest causes of lag spikes.

some pseudo code
std::vector<MySpineObject> pool; //Contains ptrs to an Atlas, a Skeleton, and a SkeletonData

void getObjectFromPool()
{
MySpineObject obj;
if(!pool.empty())
{
obj = pool.back();
pool.pop_back();
} else {
obj = MySpineObject();
}

//insert custom code here that causes the object to be reset and returned to the pool instead of being destructed
return obj;
}
So this works really well, except it causes a gradual memory leak.

I did a bit of hunting and found AnimationState->clearTracks(). Adding that to my reset code helps somewhat, but there still appears to be a small memory leak of a mb every 10-20 seconds or so.

Is there anything else I can do to my objects to make sure they're not slowly growing in size? Thanks all!
Ucenna
  • 記事: 11


Return to Runtimes