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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:02:54+00:00 2026-06-13T05:02:54+00:00

The NSString object that is got by the following code has got a retainCount

  • 0

The NSString object that is got by the following code has got a retainCount of 95.

for(GDataXMLElement *ele in [doc.rootElement elementsForName:@"myKey"])
    {
        NSLog(@"myKey %d",[[[ele.children objectAtIndex:0] stringValue] retainCount]);

        [myDict setObject:[[ele.children objectAtIndex:0] stringValue] forKey:@"myKey"];

    }

. so would it get released later when

[myDict removeAllObjects];
[myDict release];

is called.

the problem i am facing is that i have hundreds of strings like this parsed…. and all their retaincounts are around 95…would these strings get released?

  • 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-13T05:02:55+00:00Added an answer on June 13, 2026 at 5:02 am

    the problem i am facing is that i have hundreds of strings like this
    parsed…. and all their retaincounts are around 95…would these
    strings get released?

    First, retainCount is useless. Don’t call it. No, really, don’t use retainCount.

    To answer your question, look to Instruments. Do the objects that you expect to go away actually stay in memory? If so, then turn on reference count tracking and see what still holds references to them (or what retains are unbalanced).

    More likely than not, the XML subsystem is unique-ifying the strings such that only one copy of what may be repeated hundreds of times is in memory. That one copy may be retained dozens or hundreds of times as a result. When you removeAllObjects from myDict, there may still be a reference to the objects. It might even be an autoreleased reference and, thus, will actually go away.

    The only way to know is to look to see if the objects are deallocated via Instruments (or some other means).

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

Sidebar

Related Questions

the following code (from a database object created for each new view): -(void)update:(NSString *)queryText{
I have an object that got parsed into an NSString and when I trace
I've got an Mutable NSArray storing object types (ids - NSNumber, NSString) that will
I've got the following code that works OK, but I'm not sure if I
I have a NSArrayController with following Object: @interface AdressCard : NSObject <NSCoding> { NSString*
Here's an sample code, where only the string object is released. NSString *nameOfFile =
I've got a UIPickerView object that lists stores based on either a listed home
I'm trying to create a single 'query' NSString object that basically looks like this:
I am curious of the memory allocation for the following code. NSString *myString =
I've got the following two methods: -(void)playSound { NSString* filePath = [self getBasePath]; //

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.