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

  • Home
  • SEARCH
  • 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 165023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:50:52+00:00 2026-05-11T11:50:52+00:00

I was hoping someone could help me with a memory issue on the iPhone.

  • 0

I was hoping someone could help me with a memory issue on the iPhone.

I have a scrollview that is part of a nav controller.

Whenever I first push the nav controller and scroll through the scrollview (adding images as I go), memory is allocated in huge chunks (say 1mb each).

If I rotate the display a couple of times, the memory is freed, and everything is fine: The scrollview works correctly and the memory returns to where it should be (around 1mb, looking at the Net alloc in Instruments).

How can I keep the memory from going wild, or free it up during use of the scrollview, just as the device rotation does?

Here is the code snippet that is called to load the scrollview page:

- (void)loadPage:(int)page isCurrent:(BOOL)isCurrent { if (page < 0) return; if (page >= totalRows) return; picViewController *controller = [[picViewController alloc] init]; if ((NSNull *)[viewControllers objectAtIndex:page] == [NSNull null]) {         NSString *fullPath = [self fullPath];     if([fileManager fileExistsAtPath:fullPath]) {         currentImage=[UIImage imageWithContentsOfFile:fullPath];         [controller setImg:currentImage];         [viewControllers replaceObjectAtIndex:page withObject:controller];     }     else {             AsyncImageView* asyncImage = [[AsyncImageView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];             asyncImage.tag = 8;             [asyncImage loadImageFromName:imageName withURL:url];             [controller.view addSubview:asyncImage];             [asyncImage release];             [viewControllers replaceObjectAtIndex:page withObject:controller];         }         if (nil == controller.view.superview) {             CGRect frame = scrollView.frame;             frame.origin.x = frame.size.width * page;             frame.origin.y = 0;             controller.view.frame = frame;             [scrollView addSubview:controller.view];         }     [controller release];     } 

}

  • 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. 2026-05-11T11:50:53+00:00Added an answer on May 11, 2026 at 11:50 am

    I don’t see where in your code you’re actually purging off-screen pages.

    Your code is somewhat like Apple’s PageControl example, right?

    What I do is loop through the pages each time a page is ‘activated’ and purge pages more than 1 or 2 screens away. (1 for without bounce scrolling, 2 for with.)

    - (void)updateCachedPages {     int active = pageControl.currentPage;     int count = pageControl.numberOfPages;     for ( int i = 0; i < count; i++ ) {         if ( abs( active - i ) <= 2 ) {             [self loadPage:i];         }         else {             [self purgePage:i];         }     } }  - (void)purgePage:(int)page {     if ((page < 0) || (page >= [_myObjects count])) return;      MyControllerClass *controller = [_viewControllers objectAtIndex:page];     if ((NSNull *)controller != [NSNull null]) {         [_viewControllers replaceObjectAtIndex:page withObject:[NSNull null]];         //NSLog( @'Purged page %d', page );     } } 

    Call updateCachedPages in scrollViewDidEndDecelerating, your PageControl’s page change action, and viewWillAppear.

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

Sidebar

Ask A Question

Stats

  • Questions 250k
  • Answers 250k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you know the NSIndexPath of the row you just… May 13, 2026 at 9:23 am
  • Editorial Team
    Editorial Team added an answer The difference is that ".*?.*?.*?.*?.*?.*?.*?.*?.*?.*?"*50000 can be reduced to ".*?",… May 13, 2026 at 9:23 am
  • Editorial Team
    Editorial Team added an answer The UIApplication delegate has the method - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary… May 13, 2026 at 9:23 am

Related Questions

I'm building a Wine review site and have run into a database design problem
I wish to upload from my Flash Application (AS3) to imageshacks XML API. I
I was hoping someone could help me writing a regex for c++ that matches
I was hoping someone that is good with math and loops could help me

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.