cuốn sách gpt4 ai đã làm

ios - ABPersonCopyImageData 泄漏

In lại Tác giả: Walker 123 更新时间:2023-11-28 22:31:49 28 4
mua khóa gpt4 Nike

我在从 AddressBook 中获取图像时遇到了很大的问题,下面我粘贴了我的代码。此 imageData 从未被释放,在我的 Allocations Instruments 上它看起来总是在内存中它永远不会释放。

@autoreleasepool {
CFDataRef imageData = ABPersonCopyImageData(record);
if(imageData)
{
CFRetain(imageData);
CFRelease(imageData);
imageData = NULL;
imageData = nil;
}
}

câu trả lời hay nhất

您过度保留了 imageData

CFDataRef imageData = ABPersonCopyImageData(record); // Returns a +1 owned object
if(imageData)
{
CFRetain(imageData); // This is now +2
CFRelease(imageData); // This is now +1
imageData = NULL; // You've lost the pointer that lets you release it
imageData = nil; // Does nothing.
}

将它放在自动释放池中不会执行任何操作,因为您没有任何自动释放的对象。

hãy nhìn xem Core Foundation Create Rule

关于ios - ABPersonCopyImageData 泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17198294/

28 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress