我知道它有点泛泛,但是我们做了一切可能的事情来找到它是什么,而我们却做不到。Malloc创建UIImage时崩溃?
我们有这样的崩盘发生在这里和那里,并非总是如此,在这条线:
[self.imageOperationQueue addOperationWithBlock:^
{
if(!data)
return ;
UIImage *image=[[UIImage alloc] initWithData:data]; // *** CRASH !
崩溃日志说:
malloc: *** error for object 0x7fecdb06e5c0: double free
*** set a breakpoint in malloc_error_break to debug
正如你所看到的,并在我们的检查, data
不是零,当我们创建图像时,我们也尝试过:[UIImage initWithData:data];
没有分配,但同样的事情。
编辑: 这是怎样的代码看起来像这样一行之后:
if(!data)
return ;
UIImage *image=[[UIImage alloc] initWithData:data];
UIImageView *modelview=[self.allImageView objectAtIndex:index];
float newH=image.size.height* (1.65*modelview.frame.size.width/image.size.width);
CGSize s=CGSizeMake(1.65*modelview.frame.size.width, newH);
if (image)
{
UIGraphicsBeginImageContextWithOptions(s , NO, 0.0);
[image drawInRect:CGRectMake(0, 0, s.width, s.height)];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
是的,在malloc_error_break中设置一个断点来调试和启用僵尸 – Lefteris 2014-11-06 10:24:33
http://stackoverflow.com/questions/10587266/double-free-set-a-breakpoint-in-malloc-error-break-to-debug-在弧中通过这个链接。 – BHUMICA 2014-11-06 11:03:50
何不干脆[UIImage的页头] initWithData:data.copy],看看它是如何去 – 2014-11-06 13:00:07