I have a case which the instrument of Xcode detected
std::vector<UserID_t> functions::getUserIds() const {
static_assert(sizeof(int64) == sizeof(uint64_t), "size is not matched");
auto object = AAAAA::BBBB::ValueObject<int64 *>(_hash->getValue((nByte)Key::USER_IDS));
auto size = object.getSizes();
std::vector<UserID_t> ret(*size);
auto pVal = object.getDataCopy();
for (int index = 0; index < *size; index++) {
ret[index] = *pVal;
++pVal;
}
return ret;
}
The tool shows me that the elements in "ret" are not released after return. But I think int64 is a scalar variable, I don't need to release them. Is that right?
I use Xcode 6.3.2
Using auto
there with pointers (assuming they are pointers and not some class with an overloaded *
operator) is making things confusing. I think the error might be in the fact that you are creating a "copy" in object.getDataCopy()
, returning a pointer to it and not deleting it before the return of functions::getUserIds()