I got a memory leaking problem from a very simple function. Here is my code:
-(void) drawPuzzle
{
gameView.image=nil;
UIGraphicsBeginImageContext(gameView.frame.size);
[gameView.image drawInRect:CGRectMake(0,
0,
gameView.frame.size.width,
gameView.frame.size.height)];
CGContextRef con=UIGraphicsGetCurrentContext();
CGContextMoveToPoint(con, 20,0);
CGContextAddLineToPoint(con,20, gameView.frame.size.height);
CGContextStrokePath(con);
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[gameView setImage:newImage];
}
The instruments report as below:
Event Type RefCt Responsible Caller
Malloc 1 +[UIImage imageWithCGImage: scale: orientation:]
Autorelease +[UIImage imageWithCGImage: scale: orientation:]
Retain 2 -[UIImageView setImage:]
Release 1 -[NSAutoreleasePool drain]