Note that there are some explanatory texts on larger screens.

plurals
  1. POautorelease pool
    text
    copied!<p>I was hoping someone could help me with a memory issue on the iPhone.</p> <p>I have a scrollview that is part of a nav controller.</p> <p>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).</p> <p>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).</p> <p>How can I keep the memory from going wild, or free it up during use of the scrollview, just as the device rotation does?</p> <p>Here is the code snippet that is called to load the scrollview page:</p> <pre><code>- (void)loadPage:(int)page isCurrent:(BOOL)isCurrent { if (page &lt; 0) return; if (page &gt;= 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]; } </code></pre> <p>}</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload