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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:06:51+00:00 2026-05-17T16:06:51+00:00

Please, take a look at my code bellow. This part pops top view controller

  • 0

Please, take a look at my code bellow. This part pops top view controller (usually, the same ArticleControllerController) from the stack (I found that the problem stays the same no matter if I pop single controller or pop to the root controller), creates new one and adds to the stack.

The problem is, that its retain count never goes to zero and so dealloc method of ArticleControllerController is never called leaving large amounts of various interface objects unreleased. Eventually app crashes (at least in device and at least I think this part is the main problem) because of low memory.

- (void) navigateToNewsCategoryByIndex:(int)idx {
    [app.nav popViewControllerAnimated:NO]; // could be popToRootController
    ArticleControllerController *ac = [[ArticleControllerController alloc] init];
    ac.categoryIndex = idx;
    [app.nav pushViewController:ac animated:NO];
    [ac release];
    NSLog(@"AC retain count: %d", [ac retainCount]); // prints 2
} 

So, I guess, popViewControllerAnimated releases only one of the remaining two retains. Why? What should I look for? What can I do? Call [ac release] two times (that would be terrible thing)?

  • 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-17T16:06:51+00:00Added an answer on May 17, 2026 at 4:06 pm

    How do you know that a retain count of 2 isn’t correct behavior for a navigation controller?

    You can’t rely on retainCount to do alloc / release debugging because we don’t know how the internals of the UIKit work. As long as you retain and release correctly inside your code you can be 99.9% sure that UIKit will also be working correctly.

    I would guess that popViewController will remove all the retains that pushViewController added – even though I don’t know how many that would be – but it might set it to be autoreleased so you can’t guarantee that it will be released immediately after a call to popViewController.

    I’d work on the assumption that the UIKit navigation controller doesn’t have a bug (otherwise lots of other developers would be complaining about it!) and somewhere in your code you’re retaining it somewhere else (probably without realising it i.e. a delegate property declared to retain instead of assign etc)

    Hope that helps!

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

Sidebar

Related Questions

Please take a look at this code.... what is i have instead of average,
Please take a look at this code and run it: I'm getting very strange
Please take a look at this code: class Foo { public $barInstance; public function
I created a view that gets data from several tables, whenI go to compile
Update: I left the following javascript code in to show how the problem developed
Download source code here: http://www.eyeClaxton.com/download/delphi/ColorSwap.zip Yes, I want to convert something mostly blue to
Say for example that I have a Runnable called RunnableA that does something. I
In my app, I have a logs mechanism, which offer the possibility to the
I am trying to build a quick search box. it is basically a widget.

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.