我只需要一些關於內存管理的幫助。我在屏幕上顯示大約500幀。我的應用似乎在模擬器上運行良好,但在iPad上顯示大約450幀後崩潰。由於內存不足,問題似乎即將到來。以下是我的代碼的一部分。我是否正確地釋放了對象,還是有更多需要做的事情?發佈目標中的對象C
- (void)drawBufferWidth:(int)width height:(int)height pixels:(unsigned char*)pixels
{
CGRect rect = CGRectInset(self.view.bounds, 0.0, 0.0);
UIImageView *img = [[UIImageView alloc] initWithFrame:rect];
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef gtx = CGBitmapContextCreate(pixels, width, height, BitsPerComponent, BytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast);
CGImageRef myimage = CGBitmapContextCreateImage(gtx);
img.image = [UIImage imageWithCGImage:myimage];
CGContextRelease(gtx);
CGImageRelease(myimage);
CGColorSpaceRelease(colorSpace);
}
你使用ARC還是不是? – 2013-04-04 16:25:20
不,我不使用... – Ereka 2013-04-04 16:25:56
按Ctrl + f找到分配...你的IMG是分配但從未發佈 – brianLikeApple 2013-04-04 16:28:49