I know its a little bit general , but we did EVERY possible thing to find what it is, and we just couldn't .
We have this crash that happens here and there, not always, on this line :
[self.imageOperationQueue addOperationWithBlock:^
{
if(!data)
return ;
UIImage *image=[[UIImage alloc] initWithData:data]; // *** CRASH !
The crash log says :
malloc: *** error for object 0x7fecdb06e5c0: double free
*** set a breakpoint in malloc_error_break to debug
As you can see, and upon our check , data
is not nil when we are creating the image , we have also tried with : [UIImage initWithData:data];
without allocation , but same thing.
EDIT: this is how the code looks like after this row :
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();
}