Cocos2d-x-Asynchronous-Http-Request-Library icon indicating copy to clipboard operation
Cocos2d-x-Asynchronous-Http-Request-Library copied to clipboard

why not use purgeSharedHttpRequest() to prevent memory leak?

Open Huwell opened this issue 11 years ago • 0 comments

Why not call requestor->purgeSharedHttpRequest() after requestor->addDownloadTask(downloads, this, callfuncND_selector(HelloWorld::onHttpRequestCompleted));

to release the requestor object?

I added it after addDownloadTask in demo, but still find memory leak because scheduleSelector will retain request object again, but not release it, so if I use purgeSharedHttpRequest at final, the memory leak still exist.

//Add a download task to queue void CCHttpRequest::addDownloadTask(std::vectorstd::string &urls, CCObject *pTarget, SEL_CallFuncND pSelector) { bool init = lazyInitThreadSemphore(); if (!init) { return; }

if (0 == s_asyncRequestCount) {
    CCDirector::sharedDirector()->getScheduler()->scheduleSelector(schedule_selector(CCHttpRequest::httpRequestCallback), this, 0, false);
}
....

}

Huwell avatar Nov 29 '13 07:11 Huwell