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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:23:51+00:00 2026-05-22T16:23:51+00:00

I’ve read all the iOS memory allocation/deallocation basics, but can’t find anything on the

  • 0

I’ve read all the iOS memory allocation/deallocation basics, but can’t find anything on the following:

I’ve created a small app, that pretty much lists a grid of UIButtons and clicking on any of those, it adds a UIScrollView to the current controller view (and adds a bunch of UIView and UIWebView’s inside etc).

On adding the UIScrollVIew, I also add a UIButton, that takes me back to the “home grid” and then removes the UIScrollView from the superview.
I release all the things I’m retaining/allocating etc and when I check the app with Instruments, it doesn’t show any memory leak.

But every time I tap on any of the UIButton objects, I allocate more memory (according to Instruments) and it keeps growing – and “reopening” the same kind of UIScrollView from a button always adds more memory allocations.

If I simulate a memory warning in the simulator, it deallocated a bit of the memory and I can then keep growing it again.

So here’s my question: should I bother with trying to deallocate this somehow manually? And if so, where should I actually do this? I’m quite new to Obj-C, so I think I have most of the basics covered, but more advanced topics still require some help.

Creating the grid:

UIScrollView *grid = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)];
[[self view] addSubview:grid];
[grid release];

Adding buttons (in a for loop):

UIButton *slotItem = [[UIButton alloc] initWithFrame:CGRectMake(((float) slotWidth * j), ((float) slotHeight * i), (float) slotWidth, (float)slotHeight)];
[grid addSubview:slotItem];

UIWebView *buttonWebThumb = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, slotWidth, slotHeight)];

[buttonWebThumb setBackgroundColor:[UIColor clearColor]];
[buttonWebThumb setOpaque:NO];

[buttonWebThumb loadHTMLString:[NSString stringWithFormat:@"%@ %@ %@", htmlTop, [[row objectAtIndex:j] objectAtIndex:1], htmlBottom] baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
buttonWebThumb.scalesPageToFit = YES;
[slotItem addSubview:buttonWebThumb];
buttonWebThumb.userInteractionEnabled = NO;
buttonWebThumb.exclusiveTouch = NO;
[buttonWebThumb release];

[slotItem addTarget:self action:@selector(showPages:) forControlEvents:UIControlEventTouchUpInside];

[slotItem release];

showPages method then creates another UIScrollView and adds 1-10 separate UIWebView’s in there and adds a “close” button to the new UIScrollView.

  • 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-22T16:23:51+00:00Added an answer on May 22, 2026 at 4:23 pm

    You’re probably seeing this because you aren’t removing all elements from the view before leaving it.

    For example, if you exit the view with a method like this, do this:

    - (id) viewExitAction: (id) sender {
      id elem;
      for(elem in buttons) {
        [elem removeSelfFromView];
      }
      // etc
    }
    

    This will automatically decrease the retain counts of these objects down to zero. (Provided you added them to the view and then released them, as you’re supposed to.)

    Otherwise, the viewDidUnload and dealloc methods never get called.

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

Sidebar

Related Questions

I've read all recommended articles on SynchronizationContext, but there is one small question I
I just read about Mobile Device Management Server for iOS devices, but all documentations
how can i create an application to read all my browser (firefox) history? i
When you read the Class Reference of every object of iOS, you will find:
I read in the iOS Enterprise Developer Program docs that a provisioning profile can
First of all, I am a a very new Objective C/Cocoa iOS Developer but
I'm writing an ios app which browses(read only) a sqllite db. As the project
When trying to run my iOS app on a device, I get the following
i've read all possible blogs and SO post on the subject - but still
I read all over the Internet (various sites and blogs) about version control. How

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.