__Array* __Array::createWithContentsOfFile(const std::string& fileName)
{
__Array* ret = __Array::createWithContentsOfFileThreadSafe(fileName);
if (ret != nullptr)
{
// 2. this call ret->autorelease() again. !!!
ret->autorelease();
}
return ret;
}
__Array* __Array::createWithContentsOfFileThreadSafe(const std::string& fileName)
{
ValueVector arr = FileUtils::getInstance()->getValueVectorFromFile(fileName);
// 1. this call ret->autorelease() !!!!!!!!!!!!!!!!!!!!!!!!!!!
__Array* ret = __Array::createWithCapacity(static_cast<int>(arr.size()));
for(const auto &value : arr) {
ret->addObject(__String::create(value.asString()));
}
return ret;
}
And it’s not thread safe.
because put __CCArray obj in PoolManager.