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 8505247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:15:52+00:00 2026-06-11T02:15:52+00:00

I am getting a issue with NSMutableArray . I have used that to store

  • 0

I am getting a issue with NSMutableArray. I have used that to store contact details form address book. I have 300 contacts in address book.
But my app is going to crashes. I have used this code

+(NSMutableArray *)getcontactdetails
{
  ABAddressBookRef addressBook;
  CFArrayRef allSources;
  NSMutableArray *list = [[NSMutableArray alloc] init];
  addressBook = ABAddressBookCreate();
  ABRecordRef source = ABAddressBookCopyDefaultSource(addressBook);

  allSources = ABAddressBookCopyArrayOfAllPeopleInSourceWithSortOrdering(addressBook, source, kABPersonFirstNameProperty);
  CFIndex nPeople = ABAddressBookGetPersonCount(addressBook);

  if(nPeople != 0){
    for (CFIndex i = 0; i < nPeople; i++)
    {
        //common field
        NSString *first_name =[[[NSString alloc] init] autorelease];
        contact_details *phone_book_data=[[contact_details alloc] init];
        ABRecordRef aSource = CFArrayGetValueAtIndex(allSources,i);
        CFStringRef firstName = ABRecordCopyValue(aSource, kABPersonFirstNameProperty);
        first_name=[NSString stringWithFormat:@"%@",firstName];

        if ([first_name isEqualToString:@"(null)"] || first_name == nil || first_name.length == 0) {
        }
        else{
            phone_book_data.FirstName=[NSString stringWithFormat:@"%@",first_name];
        }
        [list addObject:phone_book_data];
        phone_book_data=nil;
        [phone_book_data release];

    }
    CFRelease(allSources);
  }

  [self current_function_name:@"Finished getcontactdetails"];

  return list;
 }

I have got these on console:

Sep 3 23:09:20 iPhone ReportCrash[1378] : Formulating crash report for process intooch[1373]
Sep 3 23:09:21 iPhone com.apple.launchd[1] (UIKitApplication:com.inTooch.inTooch[0x6b8a][1373]) : (UIKitApplication:com.inTooch.inTooch[0x6b8a]) Job appears to have crashed: Segmentation fault: 11
Sep 3 23:09:21 iPhone SpringBoard[52] : Application ‘inTooch’ exited abnormally with signal 11: Segmentation fault: 11
Sep 3 23:09:21 iPhone ReportCrash[1378] : libMobileGestalt computeUniqueDeviceID: total time for bb to return imei: 0

How I fixed that issue?

Thanks in advance…..

  • 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-06-11T02:15:54+00:00Added an answer on June 11, 2026 at 2:15 am

    You are leaking memory here:

    CFStringRef firstName = ABRecordCopyValue(aSource, kABPersonFirstNameProperty);
    first_name=[NSString stringWithFormat:@"%@",firstName];
    

    Just get rid of the second line altogether, all it does is introduce a memory leak.

    The release here is meaningless:

    phone_book_data=nil;
    [phone_book_data release];
    

    Since you assign nil to the pointer first, you are leaking the memory of the object it is pointing to. Swap these lines around.

    You also need to rename this method to indicate that the calling code owns the resulting object.

    You really need to read up on memory management. Start by running the static analyser, it should flag up a number of issues with this code, and don’t stop reading until you realise the cause of each warning.

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

Sidebar

Related Questions

I am having an issue getting integer values form an NSMutable array. I have
I'm getting what XCode labels an ARC Issue that I have a rather hard
I'm having an issue getting a LINQ query to work. I have this XML:
Okay, so here's the issue. I have two apps that need to package up
PHP Uploading issue Getting Error 0 but move_uploaded_file() is returning false. When I print
I'm getting a issue with the image background repeating(see image). Even though i have
Im getting issue with redirect_uri, but everything is set up properly. I had left
I am getting an issue with the remoteapi for google app engine. I have
I have an issue getting data from three tables, which I want to return
I'm getting an issue with the F# powerpack quotation evaluation. open Microsoft.FSharp.Linq.QuotationEvaluation let print

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.