Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

wlh99

macrumors 6502
Original poster
Feb 7, 2008
272
0
I have a 40 frame animation. Each frame is 24kb for a total of 960kb.
I load these into an Array and Animate in a UIImageView. 6MB of General Objects are allocated and my application ultimately crashes.

6MB is a lot of memory for an animation of less then 1MB. Is there another way to do animations that uses less memory?
 
Anyone? In Instruments when I start animating an additional 20MB of physical memory is taken, and it is released when I stop animating. This seems wrong when the animation itself is less than 1 MB.

This code demonstrates it.

Code:
- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    
    [window makeKeyAndVisible];
	int i;
	animationArray = [NSMutableArray arrayWithCapacity:39];
	[animationArray retain];
	NSString* rPath = [[NSBundle mainBundle] resourcePath];	
	NSString*  sPath;
	
	for (i=1;i<39;i++) {
		NSLog(@" interation %d",i);
		NSLog(@"rPath %@",rPath);
		sPath = [NSString stringWithFormat:@"%@/LIE2me%02d.jpg",rPath,i];
		
		
		NSLog(@"%@",sPath);
		
		
		UIImage *imgTemp = [UIImage imageWithContentsOfFile:sPath];
		[animationArray addObject:imgTemp];
		
	}
	
	NSLog(@"animation count = %d",[animationArray count]);
	[IV setAnimationImages:animationArray];
	[IV startAnimating];
	
}
 
OK. I don't get this.

Based on the code above. Testing on a real device.

Physical Memory used stays about 50MB. Physical Memory Free steadily drops to zero. Shouldn't these inversely relate to each other?

If I stop the animation, the memory is freed, if I start it again it starts dropping again. Leak? In UIImageView? Instruments doesn't find them.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.