Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7558221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:18:58+00:00 2026-05-30T12:18:58+00:00

I am getting memory leaks in the following method : – (void) SyncContactData {

  • 0

I am getting memory leaks in the following method :

- (void) SyncContactData
{
    ABAddressBookRef addressBook = ABAddressBookCreate();
    CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);
    CFIndex nPeople = ABAddressBookGetPersonCount(addressBook);

    for( int i = 0 ; i < nPeople ; i++ )
    {
        //dicContact = [[NSMutableDictionary alloc] init];

        ABRecordRef ref = CFArrayGetValueAtIndex(allPeople, i );
        NSString *str = ABRecordCopyValue(ref, kABPersonFirstNameProperty);
        NSString *strSub = ABRecordCopyValue(ref, kABPersonFirstNameProperty);
        int ii = [[NSString stringWithFormat:@"%@",strSub] length];
        if(str != nil || ii == 0)
            [arrNames addObject:strSub];
        else
            [arrNames addObject:@""];

        CFTypeRef multival = ABRecordCopyValue(ref, kABPersonPhoneProperty);
        NSArray *arrayPh = (NSArray *)ABMultiValueCopyArrayOfAllValues(multival);
        if([arrayPh count] > 0)
            [arrPhone addObject:[arrayPh objectAtIndex:0]];
        else
            [arrPhone addObject:@""];

        CFRelease(multival);

    }

    CFRelease(addressBook);
    CFRelease(allPeople);

}

Getting leaks here:

  1. NSString *str = ABRecordCopyValue(ref, kABPersonFirstNameProperty);
  2. NSString *strSub = ABRecordCopyValue(ref, kABPersonFirstNameProperty);
  3. NSArray *arrayPh = (NSArray *)ABMultiValueCopyArrayOfAllValues(multival);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T12:18:59+00:00Added an answer on May 30, 2026 at 12:18 pm

    You need to release objects that are originally copied when you are done with them:

    [str release];
    [strSub release];
    [arrayPh release];
    

    If ARC is enabled, you might need to use CFRelease instead (and cast appropriately).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am getting following memory leaks for webview initWebUILocalStorageSupport MobileQuickLookLibrary() and here is my
When i run the instrument tool i'm getting memory leaks in the following lines,(NSString
I am getting memory leaks in Instruments in the following Sqlite Code. NSArray *result
I keep getting the following memory leak using the Leaks tool in Xcode. As
Hi all i am getting memory leaks with following lines of code .how to
Hi every1 below is my code in which I'm getting memory leaks. I'm really
So Instruments tells me I have three memory leaks originating in this method (specifically,
I am new to iPhone objectiveC development. I am getting memory leaks when I
I am getting memory leaks pointing to the line NSDictionary *dw = [NSDictionary dictionaryWithContentsOfFile:path];
Iam getting memory leaks in below code. Is this is the proper way to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.