Open patriksharma opened 14 years ago
I'm having the same issue on the iPad. I'm loading 23 photos at 1024x768 and when scrolling through a level 1 memory warning I thrown. When I check in instruments each image is allocating approx 2-3 mb and at about 24mb the memory warning is thrown. The analyser doesn't show any potential leaks. It appear that the images are being released but not quick enough so too many get stored in memory.
Any one know how to improve this so images are unloaded an released the moment you move away? In therory only 3 images need to be retained, the one you ate looking at and one eitherside.
Any help would be great for this issue
(void)moveToPhotoAtIndex:(NSInteger)index animated:(BOOL)animated{
pageIndex = index;
leftButton.enabled = !(index-1 < 0); rightButton.enabled = !(index+1 >= [self.photoSource count]);
[self queueReusablePhotoViewAtIndex:index];
//[self loadScrollViewWithPage:index-1]; [self loadScrollViewWithPage:index]; //[self loadScrollViewWithPage:index+1];
EGOCache *cache = [[EGOCache alloc] init]; [cache clearCache]; [cache release];
[self.scrollView scrollRectToVisible:((EGOPhotoImageView*)[self.photoViews objectAtIndex:index]).frame animated:animated]; [self setNavTitle];
if([[[[_photoSource._comments objectAtIndex:index] objectForKey:@"numComments"] stringValue] isEqualToString:@"0"]) { [Message.customView setHidden:YES]; } else { [Message.customView setHidden:NO]; }
m_pNumComments.text = [[[_photoSource._comments objectAtIndex:index] objectForKey:@"numComments"] stringValue];
// reset any zoomed side views if (index + 1 < [self.photoSource count] && (NSNull)[self.photoViews objectAtIndex:index+1] != [NSNull null]) { [((EGOPhotoImageView)[self.photoViews objectAtIndex:index+1]) killScrollViewZoom]; } if (index - 1 >= 0 && (NSNull)[self.photoViews objectAtIndex:index-1] != [NSNull null]) { [((EGOPhotoImageView)[self.photoViews objectAtIndex:index-1]) killScrollViewZoom]; }
[self setCaptionTitle]; }
Hii the above posted function is of photoviewcontroller.m class.
Somehow iam able to fix it . i called Egocache.m class everytime to clear the last uploaded image in the photoviewer . So that there are less chance of crash
You try this function may be this helpful to you and let me know :-)
Hi Patriksharma.
The magic line in the code you posted is
The issue seems to have re appeared, not sure what is causing it
it is working fine with Iphone 4G but it is crashing in Iphone 3GS and IOA 3.1.3
As i integrated Photo viewer in my app. it is working fine in simulator But when we check it on Iphone device(3G) the app gets crash while uploading the pictures . As i found (In Instruments) the object allocation increases while uploading the pictures in the Photo Viewer . Object allocation go beyond the 23.5 MB. As i checked while debugging the application , when we click on the picture the object allocation increases from (currently) 5 MB to 15 MB(after clicking on the picture). So i think just because of object allocation app gets crash .