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 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

Related Questions

We have an interesting problem that I was hoping someone could help to shed
I was hoping someone could help me in resolving this issue. I have 3
I have 2 questions that I was hoping someone could help me with. Is
I was hoping someone could help me with a little issue I'm having trouble
I'm really hoping that someone can help. I have tomorrow to get this right
HI All I was hoping someone could help me improve a query I have
I have no idea what's going on here and was hoping someone could help,
first time poster. Was hoping someone could help me with this. In section 5.10,
I'm having trouble with one particular issue, I was hoping someone could help me
I am stuck and was hoping someone could help me. I have made a

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.