Reputation: 35
I have big problem with getting images from AddressBook, below I paste my code. This imageData never has been deallocated, on my Allocations Instruments it looks that it`s always in memory it never release.
@autoreleasepool {
CFDataRef imageData = ABPersonCopyImageData(record);
if(imageData)
{
CFRetain(imageData);
CFRelease(imageData);
imageData = NULL;
imageData = nil;
}
}
Upvotes: 0
Views: 517
Reputation: 41622
You need to CFRelease(imageData )
when you are done with it. Its a Core Foundation object - the autorrelease pool does you no good.
Upvotes: 0
Reputation: 150565
You are over-retaining 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.
}
Having this in an autoreleasepool does nothing as you don't have any autoreleased objects.
Have a look at the Core Foundation Create Rule
Upvotes: 2