question regarding memory leak detection on instruments
I am using the instrument provided with XCode 4.3 to detect memory leaks. I am getting a memory leak in the following code line. Not sure why !
self.view.backgroundColor=[[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"background-non-retina.png"]];
Can anyone kindly tell me what开发者_如何学运维 I am doing wrong here ?
Thanks
backgroundColor=[[UIColor
alloc] init...
Look carefully where it says alloc
. Anything you alloc
, init
, or new
you are required to release. Try using an autoreleased color, such as this:
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background-non-retina.png"]];
精彩评论