Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 未分配要释放的指针_Iphone_Objective C_Pointers_Malloc - Fatal编程技术网

Iphone 未分配要释放的指针

Iphone 未分配要释放的指针,iphone,objective-c,pointers,malloc,Iphone,Objective C,Pointers,Malloc,更新:我在使用beta SDK时找不到导致问题的原因,当使用最终SDK时,问题消失了。我不知道我做错了什么。很抱歉我想删除此内容,但无法删除。 您好,我有以下错误: malloc:*对象0x2087000的错误:未分配要释放的指针 *在malloc\u error\u break中设置断点以进行调试 我不知道那是什么东西。我不知道怎么找到它。有人能给我解释一下如何(以及在哪里)使用malloc_历史吗。我在malloc\u error\u break中设置了一个断点,但我无法找到该地址处的对象。

更新:我在使用beta SDK时找不到导致问题的原因,当使用最终SDK时,问题消失了。我不知道我做错了什么。很抱歉我想删除此内容,但无法删除。

您好,我有以下错误:

malloc:*对象0x2087000的错误:未分配要释放的指针 *在malloc\u error\u break中设置断点以进行调试

我不知道那是什么东西。我不知道怎么找到它。有人能给我解释一下如何(以及在哪里)使用malloc_历史吗。我在malloc\u error\u break中设置了一个断点,但我无法找到该地址处的对象。在从nsmutablearray中删除对象并手动弹出视图控制器后,我收到了此消息。如果我注释掉[reviewUpload.images removeObject:self.reviewUploadImg]这一行,它不会给我错误,但它当然对我没有用

- (void) removeImage { debugLog(@"reviewUploadImg %@", self.reviewUploadImg); debugLog(@"reviewUpload %@", self.reviewUpload); debugLog(@"reviewUploadImg thumb %@", self.reviewUploadImg.thumb); [reviewUpload.images removeObject: self.reviewUploadImg]; [self.navigationController popViewControllerAnimated:TRUE]; } -(无效)删除图像 { 调试日志(@“reviewUploadImg%@”,self.reviewUploadImg); 调试日志(@“reviewUpload%@”,self.reviewUpload); 调试日志(@“reviewUploadImg thumb%@”,self.reviewUploadImg.thumb); [reviewUpload.images-removeObject:self.reviewUploadImg]; [self.navigationController PopViewControllerInitiated:TRUE]; } 我试图打印出3个地址,但它们都不是被释放但未分配的地址

我从UIImagePickerController添加图像

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { UIImage *pickedImage = (UIImage *)[info objectForKey: UIImagePickerControllerEditedImage]; if (!pickedImage) pickedImage = (UIImage *)[info objectForKey: UIImagePickerControllerOriginalImage]; if (!reviewUpload.images) reviewUpload.images = [[NSMutableArray alloc] initWithCapacity: 5]; //UIImage *thumbImage = [pickedImage copyResizedImage: CGSizeMake(120, 120)]; UIImage *thumbImage = [pickedImage copyResizedImage:CGSizeMake(120, 120) withPaddingColor: [UIColor lightGrayColor]]; ReviewUploadImage *rui = [[ReviewUploadImage alloc] init]; rui.thumb = thumbImage; [thumbImage release]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat: @"yyyyMMddHHmmssSS"]; NSDate *date = [NSDate date]; NSString *tmpFileName = [dateFormatter stringFromDate: date]; [dateFormatter release]; NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent: tmpFileName]; NSData *imageData = [[NSData alloc] initWithData: UIImageJPEGRepresentation(pickedImage, 0.90)]; [imageData writeToFile: path atomically: TRUE]; [imageData release]; rui.path = path; [reviewUpload.images addObject: rui]; debugLog(@"rui rc %i", rui.retainCount); [rui release]; [self dismissModalViewControllerAnimated:TRUE]; } -(void)imagePickerController:(UIImagePickerController*)picker未使用信息完成PickingMediaWithInfo:(NSDictionary*)信息 { UIImage*pickedImage=(UIImage*)[info-objectForKey:UIImagePickerControllerEditedImage]; 如果(!pickeImage) PickeImage=(UIImage*)[info objectForKey:UIImagePickerController原始图像]; 如果(!reviewUpload.images) reviewUpload.images=[[NSMutableArray alloc]initWithCapacity:5]; //UIImage*thumbImage=[PickeImage copyResizedImage:CGSizeMake(120120)]; UIImage*thumbImage=[PickeImage copyResizedImage:CGSizeMake(120120)with PaddingColor:[UIColor lightGrayColor]]; ReviewUploadImage*rui=[[ReviewUploadImage alloc]init]; rui.thumb=thumbImage; [拇指图像发布]; NSDateFormatter*dateFormatter=[[NSDateFormatter alloc]init]; [日期格式化程序setDateFormat:@“yyyymmddhhmmsss”]; NSDate*日期=[NSDate日期]; NSString*tmpFileName=[dateFormatter stringFromDate:date]; [日期格式化程序发布]; NSString*path=[NSTemporaryDirectory()stringByAppendingPathComponent:tmpFileName]; NSData*imageData=[[NSData alloc]initWithData:UIImageJPEGRepresentation(PickeImage,0.90)]; [imageData writeToFile:原子路径:TRUE]; [图像数据发布]; rui.path=path; [reviewUpload.images addObject:rui]; 调试日志(@“rui rc%i”,rui.retainCount); [发布]; [self dismissModalViewControllerAnimated:TRUE]; } 我认为我在这里没有任何错误:ReviewUpload有一个图像数组,其中可能包含ReviewUploadImage对象。在这些类的实现中,我只有release方法,我只释放我必须释放的成员

@interface ReviewUpload : NSObject { NSString *title; NSString *tags; NSString *text; NSInteger rating; NSMutableArray *images; NSInteger idCompany; NSInteger idProduct; } @property(nonatomic, copy) NSString *title; @property(nonatomic, copy) NSString *tags; @property(nonatomic, copy) NSString *text; @property(nonatomic, assign) NSInteger rating; @property(nonatomic, retain) NSMutableArray *images; @property(nonatomic, assign) NSInteger idCompany; @property(nonatomic, assign) NSInteger idProduct; @end @接口评审wupload:NSObject { NSString*标题; NSString*标签; NSString*文本; NSInteger评分; NSMutableArray*图像; 恩森特格公司; NSInteger-idProduct; } @属性(非原子,副本)NSString*标题; @属性(非原子,复制)NSString*标记; @属性(非原子,复制)NSString*文本; @属性(非原子,分配)集成器评级; @属性(非原子,保留)NSMutableArray*图像; @不动产(非原子,转让)NSInteger idCompany; @属性(非原子,赋值)NSInteger idProduct; @结束 @接口评审wuploadImage:NSObject { UIImage*拇指; NSString*路径; } @属性(非原子,保留)UIImage*thumb; @属性(非原子,复制)NSString*路径; @结束 难道没有一种简单的方法可以从地址中获取objective-c对象吗

更新: 如果我删除这两行中的任何一行,我都不会得到错误。我不知道该说什么这真的很奇怪

[reviewUpload.images removeObject: self.reviewUploadImg]; [self.navigationController popViewControllerAnimated:TRUE]; [reviewUpload.images-removeObject:self.reviewUploadImg]; [self.navigationController PopViewControllerInitiated:TRUE]; 更新:如果在“didFinishPickingMediaWithInfo”中选择的图像为零,则不会显示错误。也许这与我创建缩略图的方式有关。下面是创建它的方法。如果有人有任何想法,请帮忙

-(UIImage *) copyResizedImage:(CGSize) thumbSize withPaddingColor: (UIColor *) bgColor { CGFloat resizedProp = thumbSize.width / thumbSize.height; CGFloat imageProp = self.size.width / self.size.height; CGSize newSize; CGFloat factor; if (imageProp > resizedProp) //image is wider factor = thumbSize.width / self.size.width; else factor = thumbSize.height / self.size.height; newSize.width = self.size.width * factor; newSize.height = self.size.height * factor; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; UIImage *resizedImage; UIGraphicsBeginImageContext(thumbSize); CGContextRef drwContextRef = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(drwContextRef, bgColor.CGColor); CGContextFillRect(drwContextRef, CGRectMake(0, 0, thumbSize.width, thumbSize.height)); CGRect imageRect = CGRectMake( (thumbSize.width - newSize.width) / 2.0, (thumbSize.height - newSize.height) /2.0, newSize.width, newSize.height); [self drawInRect:imageRect]; resizedImage = UIGraphicsGetImageFromCurrentImageContext(); // this is autoreleased and i dont need it UIGraphicsEndImageContext(); [resizedImage retain]; [pool release]; return resizedImage; } -(UIImage*)copyResizedImage:(CGSize)带填充颜色的拇指大小:(UIColor*)bgColor { CGFloat resizedProp=thumbSize.width/thumbSize.height; CGFloat imageProp=self.size.width/self.size.height; CGSize; CGF浮动因子; if(imageProp>resizedProp)//图像更宽 系数=thumbSize.width/self.size.width; 其他的 系数=thumbSize.height/self.size.height; newSize.width=self.size.width*因子; newSize.height=self.size.height*因子; NSAutoreleasePool*池=[[NSAutoreleasePool alloc]init]; UIImage*调整大小图像; UIGraphicsBeginImageContext(拇指大小); CGContextRef drwContextRef=UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(drwContextRef,bgColor.CGColor); CGContextFillRect(drwContextRef,CGRectMake(0,0,thumbSize.width,thumbSize.height)); CGRect imageRect=CGRectMake( (thumbSize.width-newSize.width)/2.0, (thumbSize.height-newSize.height)/2.0,newSize.width,newSize.height); [self drawInRect:imageRect]; resizedImage=UIGraphicsGetImageFromCurrentImageContext();//这是自动删除的,我不需要它 UIGraphicsSendImageContext(); [重新调整图像保留]; [池释放]; 返回resizedImage; }
当对象从数组中删除时,将发送一条dealloc消息。查看ReviewUploadImage类的dealloc函数。我看到你有一些拇指会员在那里。C -(UIImage *) copyResizedImage:(CGSize) thumbSize withPaddingColor: (UIColor *) bgColor { CGFloat resizedProp = thumbSize.width / thumbSize.height; CGFloat imageProp = self.size.width / self.size.height; CGSize newSize; CGFloat factor; if (imageProp > resizedProp) //image is wider factor = thumbSize.width / self.size.width; else factor = thumbSize.height / self.size.height; newSize.width = self.size.width * factor; newSize.height = self.size.height * factor; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; UIImage *resizedImage; UIGraphicsBeginImageContext(thumbSize); CGContextRef drwContextRef = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(drwContextRef, bgColor.CGColor); CGContextFillRect(drwContextRef, CGRectMake(0, 0, thumbSize.width, thumbSize.height)); CGRect imageRect = CGRectMake( (thumbSize.width - newSize.width) / 2.0, (thumbSize.height - newSize.height) /2.0, newSize.width, newSize.height); [self drawInRect:imageRect]; resizedImage = UIGraphicsGetImageFromCurrentImageContext(); // this is autoreleased and i dont need it UIGraphicsEndImageContext(); [resizedImage retain]; [pool release]; return resizedImage; }
backtrace -- Print backtrace of all stack frames
bt -- Print backtrace of all stack frames
down -- Select and print stack frame called by this one
frame -- Select and print a stack frame
return -- Make selected stack frame return to its caller
select-frame -- Select a stack frame without printing anything
up -- Select and print stack frame that called this one
TestWebService(740,0xa067b4e0) malloc: *** error for object 0x20e5000: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug (gdb) shell malloc_history 207 0x20e5000 malloc_history cannot examine process 207 because the process does not exist. (gdb) shell malloc_history 740 0x20e5000 malloc_history Report Version: 2.0 Process: TestWebService [740] Path: /Users/kudorgyozo/Library/Application Support/iPhone Simulator/3.0/Applications/6AF403F5-6856-44B9-A76E-45F58355535A/TestWebService.app/TestWebService Load Address: 0x1000 Identifier: TestWebService Version: ??? (???) Code Type: X86 (Native) Parent Process: gdb-i386-apple-darwin [742] Date/Time: 2010-05-06 12:02:23.167 +0300 OS Version: Mac OS X 10.6.3 (10D573) Report Version: 6 ALLOC 0x20e3800-0x20e512f [size=6448]: thread_a067b4e0 |start | main | UIApplicationMain | GSEventRun | GSEventRunModal | CFRunLoopRunInMode | CFRunLoopRunSpecific | __NSFireDelayedPerform | -[UITableView _userSelectRowAtIndexPath:] | -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] | -[PLAlbumView tableView:didSelectRowAtIndexPath:] | -[PLUIAlbumViewController albumView:selectedPhoto:] | PLNotifyImagePickerOfImageAvailability | -[UIImagePickerController _imagePickerDidCompleteWithInfo:] | -[WriteReviewImagesController imagePickerController:didFinishPickingMediaWithInfo:] | -[UIImage(Thumbnails) copyResizedImage:withPaddingColor:] | -[UIImage drawInRect:] | -[UIImage drawInRect:blendMode:alpha:] | CGContextDrawImage | ripc_DrawImage | ripc_AcquireImage | CGSImageDataLock | img_data_lock | img_interpolate_read | img_decode_read | CGAccessSessionGetChunks | getBytes_cb | getBandProcJPG | _cg_jpeg_start_decompress | _cg_jinit_master_decompress | start_input_pass | start_pass_huff_decoder | _cg_jpeg_make_d_derived_tbl | alloc_small | malloc | malloc_zone_malloc ---- FREE 0x20e3800-0x20e512f [size=6448]: thread_a067b4e0 |start | main | UIApplicationMain | GSEventRun | GSEventRunModal | CFRunLoopRunInMode | CFRunLoopRunSpecific | __NSFireDelayedPerform | -[UITableView _userSelectRowAtIndexPath:] | -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] | -[PLAlbumView tableView:didSelectRowAtIndexPath:] | -[PLUIAlbumViewController albumView:selectedPhoto:] | PLNotifyImagePickerOfImageAvailability | -[UIImagePickerController _imagePickerDidCompleteWithInfo:] | -[WriteReviewImagesController imagePickerController:didFinishPickingMediaWithInfo:] | -[UIImage(Thumbnails) copyResizedImage:withPaddingColor:] | -[UIImage drawInRect:] | -[UIImage drawInRect:blendMode:alpha:] | CGContextDrawImage | ripc_DrawImage | ripc_AcquireImage | CGSImageDataLock | img_data_lock | img_interpolate_read | img_decode_read | CGAccessSessionGetChunks | getBytes_cb | getBandProcJPG | _cg_jpeg_destroy | self_destruct | free_pool | free