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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:13:56+00:00 2026-06-08T11:13:56+00:00

I declared a Global Object: YViewController * yViewController When in App Launch I am

  • 0

I declared a Global Object:

YViewController * yViewController

When in App Launch I am calling:

[self methodOne];

The method does this:

-(void)methodOne
{
 yViewController = [[YViewController alloc] initWithNibName:@"YViewController" bundle:nil];
 self.window.rootViewController=yViewController;
}

When a button clicked in YViewController I am calling:

[self methodTwo];

The method does this:

-(void)methodTwo
{
  XViewController * xViewController = [[XViewController alloc] initWithImage:myImage];
  self.window.rootViewController=xViewController;
}

When a back button tapped on XViewController I am calling [self methodOne]; which navigates back to the YViewController.

The issue is, while I am using ARC, I could not flush/release the xViewController object. Also when checking on instruments,
the memory of XViewController keep on increasing as I tap back and forth between XViewController and YViewController.

How can I manage memory in this type of situations with ARC?

  • 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-08T11:13:58+00:00Added an answer on June 8, 2026 at 11:13 am

    If the source of XViewController is open, I would have tweaked it to go with navigation. Any ways ..

    Okay so, basically you are creating a new object of ViewController every time, and that is what is resulting in the pile of the memory.

    You should have ‘XViewController * xViewController’ and ‘YViewController * yViewController’ as class variables and your methods should be some thing like this eg.

    Look if the object exists, and if it does, don’t allocate it again.

    -(void)methodTwo
    {
     if(xViewController == nil)
     {
       xViewController = [[XViewController alloc] initWithImage:myImage];
     }
      self.window.rootViewController=xViewController;
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this Web worker which has a Global variable declared in it.
I have an MFC application in which I have declared a Global Object say
I have declared an object in my global.asax file as follows. <object Id=WFRuntime RunAt=Server
When declared as a local variable, rotating a GLfloat object does not occur. When
I have this code: private void button2_Click(object sender, EventArgs e) { //add pgs selected
The problem is with object's variable: this.timer it's not global, so when I click
I declared a global shift operator but for some reason the compiler cannot deduct
How can I fscanf for both float and double, as I declared a global
In following program . I have one doubt. I have declared one global variable
I have a vector declared as a global variable that I need to be

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.