Ere*_*eka 0 memory-management objective-c ios
我只需要一些关于内存管理的帮助.我在屏幕上显示大约500帧.我的应用程序似乎在模拟器上正常运行,但在iPad上显示大约450帧后崩溃.问题似乎是因为内存不足而来.以下是我的代码的一部分.我是否正确地释放了这些物体,还是我需要做更多的事情?
- (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);
}
Run Code Online (Sandbox Code Playgroud)
这种方法似乎正在泄漏UIImageView
您在第二行创建的内容.你alloc
没有相应的release
或autorelease
.我说"出现"因为我怀疑你没有包含所有的方法(你没有向我们展示任何与你的UIImageView做任何事情的代码......).
您对各种CGRef的管理都很好.
归档时间: |
|
查看次数: |
60 次 |
最近记录: |