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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:54:37+00:00 2026-06-08T06:54:37+00:00

I have two View Controllers, one with a grid of buttons, and the second

  • 0

I have two View Controllers, one with a grid of buttons, and the second one is a detailed description based on the button the user presses.

I’m using “Mark Heap” in Instruments allocations tool and finding that my app is increasing in memory after the user sees the detailed View Controller and then presses the back button in the navigation bar. IT should result in a net change of zero for memory… I’m using ARC, xcode 4.2.1, deploying to ios 5.0+

When I load the new ViewController after the button press, I load some data images in a background thread. Is it possible that because I’m pressing the back button quickly, that data is still being loaded in the background thread and is never released from memory?

  • 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-08T06:54:38+00:00Added an answer on June 8, 2026 at 6:54 am

    from the slides from the class i had that described memory cycles problem you may be facing:

    what if you had the following property of a class?

    @property (strong, nonatomic) NSArray* myBlocks;    // array of blocks
    

    and then tried to do the following in one of that class’s methods?

    [self.myBlocks addObject:^() {
        [self doSomething];
    }];
    

    all objects referenced inside a block will stay in the heap as long as the block does. (in other words, blocks keep a strong pointer to all objects referenced inside of them.)

    in this case, self is an object referenced in this block. thus the block will have a strong pointer to self. but notice that self also has a strong pointer to the block (through its myBlocks proeprty)

    THIS IS A SERIOUS PROBLEM!

    neither self nor the block can ever escape the heap, now. that’s because there will always be a strong pointer to both of them (each other’s pointer). this is called a memory “cycle”.

    solution:

    local variables are always strong. that’s okay, because when they go out of scope, they disappear, so the strong pointer goes away. but there’s a way to declare that a local variable is weak. here’s how …

    __weak MyClass* weakSelf = self;
    [self.myBlocks addObject:^{
        [weakSelf doSomething];
    }];
    

    this solves the problem because now the block only has a weak pointer to self. (self still has a strong pointer to block, but that’s okay) as long as someone in the univese has a strong pointer to this self, the block’s pointer is good. and since the block will not exist if self does not exist (since myBlocks won’t exist), all is well!

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

Sidebar

Related Questions

I have two view controllers, one is main and second is detail. Whenever I
I have application where i have two view controllers my first view and second
Currently using Xcode 4.2 and I have two view controllers (1 and 2). I
So I have two view controllers in my iphone project - one of them
I have two view controllers, in which I am using navigation controller to navigate
I have two view controllers. In one of them I have a UITextField within
I have two view controllers and nibs. I populated one view controller with a
I have two view controllers and nibs. I populated one view controller with a
I have a UITabBarController that contains two view controllers. One is the default view
Want to use two models in one view. I have two controllers one for

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.