-
Notifications
You must be signed in to change notification settings - Fork 189
Open
Description
- APAddressBook/Core (0.3.1)
- APAddressBook/Swift (0.3.1)
We're using APAddressBook to load native contacts to search against. However, for some of our users who have > 10k native contacts, the app seems to be consuming too much memory, causing an unexpected JetSam event and terminating the app.
Looking at the method where contacts are being extracted:
- (NSArray *)allContactsWithContactFieldMask:(APContactField)fieldMask
{
NSMutableArray *contacts = [[NSMutableArray alloc] init];
if (!self.wrapper.error)
{
CFArrayRef peopleArrayRef = ABAddressBookCopyArrayOfAllPeople(self.wrapper.ref);
CFIndex count = CFArrayGetCount(peopleArrayRef);
for (CFIndex i = 0; i < count; i++)
{
ABRecordRef recordRef = CFArrayGetValueAtIndex(peopleArrayRef, i);
APContact *contact = [self.builder contactWithRecordRef:recordRef fieldMask:fieldMask];
[contacts addObject:contact];
}
CFRelease(peopleArrayRef);
}
return contacts.count > 0 ? contacts.copy : nil;
}
Would it be better if we call this method using an autorelease pool and batching up contacts? Is there a better way to handle the large volume of contacts with APAddressBook?
Metadata
Metadata
Assignees
Labels
No labels