开发者

question regarding memory leak detection on instruments

开发者 https://www.devze.com 2023-03-27 21:51 出处:网络
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 !

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=[[UIColoralloc] 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"]];
0

精彩评论

暂无评论...
验证码 换一张
取 消