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

The Archive Base Latest Questions

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

NSMutableArray *tempData=[[NSMutableArray alloc]init]; TBXMLElement * city = [TBXML childElementNamed:@city parentElement:root]; while(city!=nil){ if([TBXML valueOfAttributeNamed:@name forElement:city]!=nil){

  • 0
NSMutableArray *tempData=[[NSMutableArray alloc]init];  
    TBXMLElement * city = [TBXML childElementNamed:@"city" parentElement:root];
    while(city!=nil){
        if([TBXML valueOfAttributeNamed:@"name" forElement:city]!=nil){
        NSString *tempDataHolder=[NSString stringWithFormat :@"%@,%@",[TBXML valueOfAttributeNamed:@"name" forElement:city],[TBXML valueOfAttributeNamed:@"country_name" forElement:city]]; 
        [tempData addObject:[tempDataHolder copy]];         
        [tempDataHolder release];
               }
city = [TBXML nextSiblingNamed:@"city" searchFromElement:city];         

    }
    tableData=[tempData copy];
    [tableCities reloadData];
    [tempData release];

Instruments with Memory leaks says there is a leak of multiple NSCFStrings,i have been trying to figure it out for a while, any help is highly appreciated.

Thanks

edit: The above set of code runs a few times, and i have a bunch of leaks referring to NSCFString – NSPlaceholderString. I am releasing tempDataHolder almost immediately and the rest of the variables are being released as well. I cant pin point on where the leak is.

  • 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-18T12:39:52+00:00Added an answer on May 18, 2026 at 12:39 pm

    Copied objects need to be released by the owner. That is, the copy method returns a new object that has a retain count of 1. In your situation, the culprit seems to be this line:

    [tempData addObject:[tempDataHolder copy]];
    

    Containers retain their elements, but the copied object already has a retain count of 1 before being inserted in the array. The copied object is therefore leaking.

    Simply adding tempDataHolder in your array (not a copy) should solve it.

    Also, tempDataHolder is an auto-released object and shouldn’t be released explicitly.

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

Sidebar

Related Questions

NSMutableArray *a1 = [[NSMutableArray alloc] init]; NSMutableArray *a2 = [NSMutableArray array]; TempObj *obj =
NSMutableArray *persons = [ [ NSMutableArray alloc ] init ]; How can I edit
NSMutableArray *insideArray = [[NSMutableArray alloc] init]; NSMutableArray *outsideArray = [[NSMutableArray alloc] init]; [insideArray addObject:@Hello
I create an NSMutableArray: SBJsonParser *parser = [[SBJsonParser alloc] init]; NSMutableArray *components = [parser
NSMutableArray *myArray = [[NSMutableArray alloc] init]; MyClass *obj1 = [[MyClass alloc] init]; [myArray addObject:
I have a class that subclasses NSMutableArray. I init it using: MyClass class =
NSMutableArray *Number=[NSArray arrayWithObjects: @1, @2, @3, @4, @5, @6, nil]; I have an array
NSMutableArray *array = [[NSArray alloc] initWithObjects:@Apranax Forte, @Actified, @Zostex 125 MG, @Zoprotec 30 MG,
-(NSMutableArray *)processResult:(NSArray*)matchArray removeString:(NSString *)removeStr{ NSString *newLink; NSMutableArray *result = [[NSMutableArray alloc] initWithCapacity:[matchArray count]]; //doing
NSMutableArray *tblContents = [NSMutableArray arrayWithObjects: @1, @2, @3, nil]; [tblContents addObject:txtNewTableRow.text]; My app is

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.