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

The Archive Base Latest Questions

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

I recently changed my app to use a UINavigationController, I was using a UINavigationBar

  • 0

I recently changed my app to use a UINavigationController, I was using a UINavigationBar before, with cascade subView adding, which was a bit tenuous.

I’m facing a problem of memory usage. Leaks tool doesn’t show any leak, but ViewControllers I create and add to the UINavigationController never seem to be released. So memory usage grows everytime I create a new VC and then press the NavigationController’s back button.

I simply create and add my VCs this way:

DetailViewController* detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
// setups
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];

The app never goes through ViewController’s dealloc and viewDidUnload methods. Shouldn’t these be called everytime I press the back button?

I’ve searched many tutorials and read Apple’s memory management, but there’s nothing about VC’s lifetime in memory when using NavigationController.

  • 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-15T20:01:29+00:00Added an answer on May 15, 2026 at 8:01 pm

    Maybe you are not doing something wrong and instead you are facing something like this

    In the Blog post it was the question whether we have to manually release IBOutlets or not. As it turns out we should. This was reproduceable in iOS 3.1.3 but I didn’t test it in iOS 4.0 yet.

    The second aproach is to override your view controllers retain and release method and print out the retain count. I had a simimlar problem, that some view controllers dealloc method did not called so I override this methods to see wether someone has still a retain on it. As it turns out it did.

    Edit:
    When I printed my retain count, it would sometimes reach ~98 caused from the framework, so thats not really to worry.

    If your last retain count stays at 2 and the dealloc method won’t be called, than there is someone that has still a retain on it.

    In this case you should search on other places.

    For example another problem I encountered during this same problem:
    Sometimes I would use

    [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateUI) userInfo:nil repeats:YES]

    to constantly update the UI. But what I forgot was, that the NSTimer will retain the target object (which was the ViewController). Because the NSTimer retained your view controller your dealloc will never be called because someone (NSTimer) has still a retain on it. So you have to make sure to invalidate the NSTimer BEFORE dealloc method to properly release the view controller.

    Edit2 in response for a comment below:
    A retain declaired property does as follows (exsample):

    - (void)setTarget:(id)value {
      if (value != target) { 
        [target release];
        target = [value retain];
    }
    

    So it does first release your current self.target then retains the new value. Since you are assigning nil your target will be nil afterwards. Further info about Properties can be found in the Apple doc.

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

Sidebar

Ask A Question

Stats

  • Questions 491k
  • Answers 491k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer ah. i found the answer. Markdown markdown = new Markdown();… May 16, 2026 at 10:17 am
  • Editorial Team
    Editorial Team added an answer Wouldn't you be better off trying to pass exceptions down… May 16, 2026 at 10:17 am
  • Editorial Team
    Editorial Team added an answer WinGDI.h ln 640: #define GetYValue(cmyk) ((BYTE)((cmyk)>> 8)) Gotta love windows.h… May 16, 2026 at 10:17 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I recently changed some URLs in my Rails app and am curious if I'm
I was using SortedList() in a class which stores about 15-100K data. Recently my
Recently I was going through a blog and noticed some points about using PDO
Recently, when I tried to show the results of my work (some Flex app)
I've started to learn Ruby recently, and was wondering about which version to learn.
I have a Django app, which populates content from a text file, and populates
I recently started using Mercurial and like the way I have VCS protection for
In VB.NET (using Visual Studio 2008) my WCF service has an interface something like:
Please, help me clear my mind on the following question. Recently I asked a
I have an aspnet webapp which has worked very well up until now. I

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.