【发布时间】:2013-03-16 00:01:56
【问题描述】:
我正在使用ScreenCaptureView. 进行视频录制
我使用了以下代码;
-(CGContextRef) createBitmapContextOfSize:(CGSize) size
{ CGContextRef context = NULL; CGColorSpaceRef colorSpace; int bitmapByteCount;
int bitmapBytesPerRow;
bitmapBytesPerRow = (size.width * 4);
bitmapByteCount = (bitmapBytesPerRow * size.height);
colorSpace = CGColorSpaceCreateDeviceRGB();
if (bitmapData != NULL)
{
free(bitmapData);
}
bitmapData = malloc( bitmapByteCount );
if (bitmapData == NULL)
{
fprintf (stderr, "Memory not allocated!");
return context=NULL;
}
context = CGBitmapContextCreate (bitmapData, size.width, size.height, 8, bitmapBytesPerRow,colorSpace, kCGImageAlphaNoneSkipFirst);
CGContextSetAllowsAntialiasing(context,NO);
if (context== NULL)
{
free (bitmapData);
fprintf (stderr, "Context not created!");
return NULL;
}
return context;
CGContextRelease(context);
CGColorSpaceRelease(colorSpace);
}
但它给了我潜在的内存泄漏警告和应用程序崩溃。
它在 ipod 中运行良好,但在 ipad 中崩溃。
我该如何解决?
谢谢......
【问题讨论】:
-
@Maulik - 感谢您的编辑。也请给出问题的答案...!!! Mogs.. :-)
-
你试过@autoreleasepool吗?
-
@Ganapathy - 不,我没有尝试过 autoreleaseool。怎么用?
-
这个位图数据是什么?
-
@user2135853:哇……你的崩溃日志是什么?
标签: iphone ios objective-c xcode memory-leaks