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

  • Home
  • SEARCH
  • 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 7176167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:27:15+00:00 2026-05-28T16:27:15+00:00

I have a problem regarding the memory management when adding objects to a NSMutableArray

  • 0

I have a problem regarding the memory management when adding objects to a NSMutableArray. Weird thing is that it’s all working fine for the first 8 objects I add, but when adding a 9th, the application crashes when retrieving this object.

UploadStatus *status = [[UploadStatus alloc] initWithStatus:[NSString stringWithFormat:@"%@: %d", NSLocalizedString(@"uploadPictureSucceeded", @""), pic_id] 
                                                 andImageInProgress:nil 
                                                    imageForSuccess:nil 
                                                     imageForFailed:nil];
[self.delegate notify:status];
[status release];

This is being done on several places with different texts. But this object contains my status that I display in a UITableView.

In the notify method of the delegate I add the UploadStatus object to the NSMutableArray and I reload the UITableView that shows the objects inside that array.

The first 8 times I add a UploadStatus object to the array and reload the table, it shows correctly. But the 9th time I get the error [CFString retain]: message sent to deallocated instance 0x5c655c0. This error occurs when reloading the table in the cellForRowAtIndexPath method.

Weird thing is that it always shows that the objects inside the NSMutableArray are out of scope like in this screenshot:

enter image description here

Nevertheless if I fetch the item, convert it into the UploadStatus class and get the status from it, it all goes smoothly (for the first 8 objects).

Does anybody have a clue why it goes wrong after adding the 9th UploadStatus object to the NSMutableArray?

Thanks a lot for your help!

  • 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-28T16:27:15+00:00Added an answer on May 28, 2026 at 4:27 pm

    The problem is with this code:

    [NSString stringWithFormat:@"%@: %d", NSLocalizedString(@"uploadPictureSucceeded", @""), pic_id]
    

    You aren’t retaining the string, so it goes away on the next execution of the run loop. You’re getting lucky with the first 8. They happen to not get overwritten for some reason, or possibly some other object is retaining them. But the 9th one isn’t and you finally see the results of the mistake.

    You need for the UploadStatus object to retain that string (and later release it).

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

Sidebar

Related Questions

I have a question regarding some memory management in C. I have to allocate
I have a basic question regarding memory management in TCL. Suppose I have a
I have a problem regarding getting the path of a user control. The scenario
I have a problem regarding StartUp Url in WPF. I have a LoginView.xaml and
I have a problem regarding the datediff MYSQL function, I can use it and
I have a question regarding a problem with L2S, Autogenerated DataContext and the use
I actually have two questions regarding the same problem but I think it is
I have problem in some JavaScript that I am writing where the Switch statement
I have a problem related to Memory Leak. In my app I have to
I have a problem with a MySql server causing it to freeze all the

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.