Hi guys.
Looks like there’s a problem with an Obj-C objects created within loading thread - autorelease pool is created in thread but it’s never drained. TextureCacheTest causes constant heap growth and eventually leads to a crash being repeated enough times.
Something like that seems to work:
-
Append drain method to CCThread definition.
void CCThread::drainAutoreleasePool()
{
[(id)m_pAutoreasePool drain];
} -
Call it every time asyncronous resource loading is finished:
static void* loadImage(void* data)
{
[…]
pthread_mutex_lock(&s_ImageInfoMutex);
s_pImageQueue->push(pImageInfo);
pthread_mutex_unlock(&s_ImageInfoMutex);
thread.drainAutoreleasePool();
thread.createAutoreleasePool();
}
return 0;
}
I’m not sure if it’s a Right Way to handle an autorelease pool, I’m quite incompetent in Obj-C.