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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:35:36+00:00 2026-06-10T15:35:36+00:00

My application started out as viewbased but I had to change to navigation based

  • 0

My application started out as viewbased but I had to change to navigation based later on. The way I did this was by creating a UINavigationController member in my AppDelegate and calling pushViewController in the didFinishLaunchingWithOptions method:

@property (nonatomic, retain) IBOutlet UINavigationController *navigator;

// didFinishLaunchingWithOptions implementation
MainController *mainView = [[MainController alloc] initWithNibName:@"MainController" bundle:nil];
navigator = [[UINavigationController alloc]init];
[navigator pushViewController:newSongView animated:YES];
[mainView release];

In my MainController view I have a button that calls this method and sends the user to the next view:

- (IBAction)newViewLoader:(id)sender {
    SecondViewController *secVC = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
    [self.navigationController pushViewController:secVC animated:YES];
}

This works fine but the moment this button is pressed, the simulator starts using 5MB more of the memory. And when I press the back button on the navigation bar and than press the button that calls the newViewLoader method, 5MB more is taken by the simulator. And so on, every time the second view is loaded. So loading this view is quite expensive.

Isn’t there some way to unload the view when the back button is pressed, so that memory doesn’t keep going up every time the view is opened? Here’s a screenshot with what happens every time the view is loaded.

  • 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-10T15:35:38+00:00Added an answer on June 10, 2026 at 3:35 pm

    If you’re not using ARC then you have at least one memory leak in your IBAction. It should be:

    - (IBAction)newViewLoader:(id)sender {
        SecondViewController *secVC = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
        [self.navigationController pushViewController:secVC animated:YES];
        [secVC release];
    }
    

    or what I prefer:

    - (IBAction)newViewLoader:(id)sender {
        SecondViewController *secVC = [[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil] autorelease];
        [self.navigationController pushViewController:secVC animated:YES];
    }
    

    Otherwise you secVC is never released. You could try adding the release and see what happens.

    However you really should be using ARC, which is Automatic Reference Counting. This takes care of the releases for you. Read up on it here: http://developer.apple.com/library/ios/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html

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

Sidebar

Related Questions

I'm developing an iPhone application and I started out with the navigation based template.
I am new to creating a facebook application and hence started out with a
I am working on a multi-threaded application. This application started out as a single
I've started out with the Silverlight 4 Navigation Application template (RIA Services enabled). (As
I started out with the Master-Detail application in XCode 4.2. It is my first
I have Silverlight Application. Getting started with Linq I find out I have to
Our web application started out as a big, honkin' ASP.NET AJAX 'page' with oodles
I just started out using IronRuby (but the behaviour seems consistent when I tested
This is a project I'm doing for my own amusement. I started out wanting
I'm working on a Java EE 6 application. When I started out, I was

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.