Memory leak in mutablearray allocation

Posted by Srilakshmi Manthena on Stack Overflow See other posts from Stack Overflow or by Srilakshmi Manthena
Published on 2010-03-23T13:01:04Z Indexed on 2010/03/23 13:03 UTC
Read the original article Hit count: 209

Filed under:
        Hi


        I am getting memory leak in mutablearray allocation.. in


        NSMutableArray *contactsArray =[[NSMutableArray alloc] init]; 


CODE:

+(NSMutableArray*)getContacts {

addressBook = ABAddressBookCreate();



NSArray* peopleArray =  (NSArray*) ABAddressBookCopyArrayOfAllPeople(addressBook);

int noOfPeople = [peopleArray count];

    NSMutableArray *contactsArray =[[NSMutableArray alloc] init]; 

    for ( int i = 0; i < noOfPeople; i++)
{
    ABRecordRef person =   [peopleArray objectAtIndex:i];
    ABRecordID personId = ABRecordGetRecordID(person);
    NSString* personIdStr = [NSString stringWithFormat:@"%d", personId];

    ContactDTO* contactDTO = [AddressBookUtil getContactDTOForId:personIdStr];


    [contactsArray addObject:contactDTO];

}
[peopleArray release];
return contactsArray;

}

© Stack Overflow or respective owner

Related posts about objective-c