我做的使用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 .. :-) – Manthan 2013-03-26 09:06:00
你用@autoreleasepool试过了吗? – Ganapathy 2013-03-26 09:07:57
@Ganapathy - 不,我还没有尝试过autoreleaseool。如何使用它? – Manthan 2013-03-26 09:09:15