Async texture loading seems to leak on iOS due to autorelease pool issues.

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:

  1. Append drain method to CCThread definition.
    void CCThread::drainAutoreleasePool()
    {
    [(id)m_pAutoreasePool drain];
    }

  2. 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.

May be it is a bug.
#1087 is created, thank you.