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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:05:55+00:00 2026-06-09T15:05:55+00:00

I apologise if this a silly question but I’m very new to iOS development.

  • 0

I apologise if this a silly question but I’m very new to iOS development. So here is the question:

when I add the SecondView to the FirstView, the memory is allocated but when I remove it, not all of the allocated memory are released.

Here’s the code:

FirstView:

@interface FirstView : UIViewController
@property (nonatomic, retain) SecondView *secondView;
- (IBAction)loadSecondView;
@end

@implementation ViewController
@synthesize editView;
- (IBAction)loadSecondView{
    secondView = [[SecondView alloc]init];
    [self presentModalViewController:editView animated:YES];
}
- (void)viewWillAppear:(BOOL)animated{
    [secondView release]; secondView = nil; //this is called after SecondView is removed
}

SecondView:

@interface SecondView : UIViewController
@end

@implementation EditView
-(void)viewDidLoad{
    for (int intCounter = 0; intCounter < 10000; intCounter++){
        UIImageView *image = [[UIImageView alloc]init]; //create 10000 images just to fill up the memory
        [self.view addSubview:image];

        [image release]; image = nil;
    }
}
@end

Here are some numbers I got from Instruments (Live Bytes):

  1. FirstView loaded: 671 KB
  2. SecondView loaded: 3.28 MB
  3. SecondView removed: 809 KB

Note: Instruments shows no leak

Shouldn’t the Live bytes become the initial value (671 KB)? instead of 809 KB, what is left over?

  • 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-09T15:05:57+00:00Added an answer on June 9, 2026 at 3:05 pm

    This is not leak. Apple caches some of the details. First time when you load viewcontroller, it will increase the memory usage. Once you dealloc it, some of the things will remain cached.

    So, first readings will not give you exact picture.

    Carry the same exercise for 2-3 times. So, you should able to have same memory utilization at the start of 3rd iteration and at the end of 3rd iteration.

    If it increases at each cycle, then there might be a case of memory leak.

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

Sidebar

Related Questions

I'm new to iPhone development, so apologies if this is a silly question, but
Im completely new to Android so apologies if this is a silly question. But
I'm new to backbone.js and MVC so apologise if this is a silly question...
I appreciate this question is a little silly, so I apologise in advance if
I apologize if my question turns out to be silly, but I'm rather new
Ok, I'm still pretty new to iOS development, so I apologize if this is
I apologize in advance because this is somehow a silly question, but I just
Did ask a question about the same problem here: Silly problem with UTF8 but
Apologies in advance if this is a silly question, am very much a beginner.
Sorry if this is a silly question but lately I've been designing a site

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.