Quote:
Originally Posted by smasher
If instruments says your net memory is going up continuously then you aren't releasing something properly. If you use the Object Allocations instrument and set an "inspection range" you should be able to tell what kind of objects are being created. You can also look at the net number of UIImage or UIImageView objects and see if that's what's increasing over time.
If it looks like those objects are the problem, then post an example of how you're adding an image to the screen.
|
Here are two methods for loading images, creating animations
-(NSArray *)loadImpactImages

NSString *)file_prefix

NSInteger)loop_start

NSInteger)loop_end
{
//set an array for computer impact images
NSMutableArray *imageArray =[NSMutableArray array];// [[NSMutableArray alloc] init];
//imageArray=nil;
NSString *cname;
NSString *imagePath;
int i;
UIImage *img;
for (i = loop_start; i <=loop_end ; i++) {
if([file_prefix isEqualToString:@"eclat vitre_00"])
{
//this is only for glass break aniamtion
cname = [NSString stringWithFormat:@"%@%d.png",file_prefix, i];
}
else
{
cname = [NSString stringWithFormat:@"%@%@%03d",levelPrefix,file_pref ix, i];
imagePath = [[NSBundle mainBundle] pathForResource:cname ofType:@"png"];
}
//UIImage *img = [UIImage imageNamed:cname];
img = [UIImage imageWithContentsOfFile:imagePath];
if (img)
{
[imageArray addObject:img];
}else{ NSLog(@"%@ not found",cname);}
img=nil;
pauseState=file_prefix;
pauseStateFrameNo = loop_end;
//}else{ NSLog(@"%@ not found",cname);}
}
//z [imagesCopy arrayByAddingObject:imageArray];
return imageArray;
}
//general function for animating the object moves
-(void)myAnimateObject{
//if(movingObject!=nil && sizeof(listdata)>0)
//{
movingObject.animationImages = listdata;
if(speed != customAnimationSpeed)
{
movingObject.animationDuration = customAnimationSpeed;
}
else
{
movingObject.animationDuration = speed ;//speed * ([listdata count]);
}
//movingObject.animationDuration = 0.5;// speed * ([listdata count]);
movingObject.contentMode = UIViewContentModeBottomLeft;
if(repeatAnimation==0)
{
[movingObject setAnimationRepeatCount:1];
}
[self.view addSubview:movingObject];
//NSLog(@"Added subview %@", movingObject);
[movingObject startAnimating];
self.pauseImage=[listdata objectAtIndex

[listdata count]-1)];
movingObject.image=pauseImage; // logic to put last image of animation just after finishing the animation
[self.view bringSubviewToFront:glassCrackObject];
}