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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:54:57+00:00 2026-05-17T15:54:57+00:00

So my code goes like this: ArticleControllerController *ac = [[ArticleControllerController alloc] init]; ac.categoryIndex =

  • 0

So my code goes like this:

ArticleControllerController *ac = [[ArticleControllerController alloc] init];
ac.categoryIndex = idx;
NSLog(@"acc retain: %d", [ac retainCount]);        
[app.nav pushViewController:ac animated:NO];
NSLog(@"acc retain: %d", [ac retainCount]);        
[ac release];
NSLog(@"acc retain: %d", [ac retainCount]);    

And I get:

[2649:207] acc retain: 1
[2649:207] acc retain: 3
[2649:207] acc retain: 2    

How to resolve this mess? I don’t understand what I’m doing wrong and this part sometimes causes application crash due low memory.

Edit: related problem.

So the situation is the same as defined above, but the problem is that ArticleControllerController dealloc method never gets called.

More code:

- (void) navigateToNewsCategoryByIndex:(int)idx {
[app.nav popViewControllerAnimated:NO]; 

currentMode = MODE_ARTICLE;
ArticleControllerController *ac = [[ArticleControllerController alloc] init];
ac.categoryIndex = idx;
[app.nav pushViewController:ac animated:NO];
[ac release];
return ;        

}

If this method gets repeated several times ArticleControllerController creates massive amounts of various interface elements, but its dealloc method never releases them (retain count never goes down to zero), so I think here lies the memory-crash problem I am trying to resolve for a couple of days now.

What’s up with that? Can I do something more to resolve this?

  • 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-17T15:54:57+00:00Added an answer on May 17, 2026 at 3:54 pm

    That looks fine to me. After you’ve created it ‘ac’ has a retain count of 1 which is correct. Then you push it to app.nav and in there a further two retains are counted which is fine. It is the responsibility of that class to release whatever it retains. Finally you release the instance you have created and the retain count goes down to 2. But those two counts are not your responsibility, that is app.nav.

    This is why you should not really worry about printing out retainCount as it can look weird when you don’t know what is going on behind the scenes in another class.

    All you need to do is one release for every alloc and you have done that

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

Sidebar

Related Questions

My code goes like this: URL url; URLConnection uc; StringBuilder parsedContentFromUrl = new StringBuilder();
While trying to do some operation with files the code goes like this, File
I have a form that contains and form of which code goes like this
I am learning about cronjob and I found this piece of code in one
I have the the following code in a script that I am learning from
Hopefully this is not a ServerFault question... I'm working forward on migrating a project
I'm looking for a way to mark when text overflows it's container. The code
My application downloads and displays favicons for specific websites. I followed Bing's solution for
C++. Its may be more question of debugging in Visual Studio and working with

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.