Iphone 关于内存泄漏问题
我是iPhone开发新手。以下代码中存在内存泄漏问题。如果有人知道为什么会这样,请帮助我Iphone 关于内存泄漏问题,iphone,Iphone,我是iPhone开发新手。以下代码中存在内存泄漏问题。如果有人知道为什么会这样,请帮助我 for(int i=0;i<size;i++) { NSString *CellIdentifier1; if(universalApp==2) { CellIdentifier1 = @"CustomThumbImageTableCell_iphone"; cell = [[[CustomThumbImageTableCell alloc] initWithF
for(int i=0;i<size;i++)
{
NSString *CellIdentifier1;
if(universalApp==2)
{
CellIdentifier1 = @"CustomThumbImageTableCell_iphone";
cell = [[[CustomThumbImageTableCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier1] autorelease];
//NSLog(@">>>>> Creating image >>>>>>>>");
cell.thumbImageView = [[CustomImageView alloc] initWithFrame:CGRectMake(4, 4, 83, 101)];
[imgViewArray addObject:cell.thumbImageView];
[cell.thumbImageView release];
}
对于(int i=0;i此外,使用自动释放池
for(int i=0;i<size;i++) {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
...
cell.thumbImageView = [[[CustomImageView alloc] initWithFrame:CGRectMake(4, 4, 83, 101)] autorelease];
...
[pool release];
}
for(int i=0;我使用build and analysis
yes.我这样做了。它在“cell.thumbImageView=[[CustomImageView alloc]initWithFrame:CGRectMake(4,4,83,101)];”中泄漏,“但我也释放了该对象..您是否尝试像这样在下面的行中自动删除CustomImageView?cell.thumbImageView=[[[CustomImageView alloc]initWithFrame:CGRectMake(4,4,83,101)]autorelease];
只是一个指针…addObject也分配内存…感谢您的回答。我也尝试了这个方法,但在同一个地方出现了内存泄漏。我修改了答案并留下了评论。