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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:06:22+00:00 2026-05-27T12:06:22+00:00

I am in the process of learning objective-C in my own time and creating

  • 0

I am in the process of learning objective-C in my own time and creating my first iPhone application however I seem to be having problems releasing the memory of my allocated views. I think there is to much code to include in the question itself so I have created a small sample application and uploaded the code to github (here: https://github.com/MatthewStacey/PauseTest).

In the sample app I have three views, a main page, a game page and a pause view.

On the Main page there is a button which will take you to the game page (with fade in/out animation).

On the game page there is a button which will display the pause view (UIView).

On the pause view there are two buttons, one which will hide the view and leave the game page being displayed and another which will display the main menu.

Functionality wise the sample app does what it is supposed to do (i.e. there are no leaks and the appropriate views are displayed), however when I look at the app in Instruments Activity Monitor the memory being used continually increases as you show/hide the three different views.

I have spent the best part of two weeks reading and trying to figure out what I am not releasing correctly to no avail. Could someone please take a look at the project I have uploaded to github and tell me where I am going wrong and how I can overcome this problem?

I am happy to provide more information/clarification if it is needed. Please note I have targeted iOS4.

  • 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-27T12:06:23+00:00Added an answer on May 27, 2026 at 12:06 pm

    You are leaking PauseViews.

    In your GAME.m file, in the pausePressed method, you create a new instance of your PauseView class. When you add that as a subview to something, it gets retained by the superview. After the pausePressed method returns, you no longer have a reference to the PauseView and therefore cannot release it. On a related note, in your PauseView class’ dealloc method, you have “[self removeFromSuperview]”. This does not make sense, because if it had a superview at that point, it would have a retainCount of at least one, but then dealloc would never have been called in the first place. Put a breakpoint in the dealloc method of PauseView, and you’ll see that it never gets called.

    I used this method to find it:
    http://useyourloaf.com/blog/2011/3/8/using-heapshots-to-find-abandoned-memory.html

    Create an ivar for your PauseView, and try this for your pausePressed method:

    - (IBAction) pausePressed
    {
        CGRect startFrame = CGRectMake(0, -500, 320, 480);
        if (!pv) {
            pv = [[PauseView alloc] initWithFrame: startFrame :10 :3];
            [pv setDelegate: self];
            [self.view addSubview:pv];
        }
        pv.frame = startFrame;
        [pv showPauseView];
    }
    

    And don’t forget to release the ivar in dealloc.

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

Sidebar

Related Questions

I'm in the process of learning Objective-C for the iPhone and the biggest hurdle
I am in the process of learning Objective-C for Mac/iPhone development and decided to
I'm in the process of learning Scheme. I recently spent (too much!) time trying
I'm in the process of learning WPF and am currently looking into application commands
sorry for the silly question, but I'm still in the process of learning Objective-C
I am just learning objective-c and iPhone development, and I am really struggling with
I am learning Objective-C, I will be developing a video processing application. I am
I'm in the process of learning Objective-c but would like to run code snippets
I am in process of learning c++. I am working on creating a linkedlist
I'm currently learning Objective C and in the process I've made the silly little

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.