Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.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 - Fatal编程技术网

Iphone 关于内存泄漏问题

Iphone 关于内存泄漏问题,iphone,Iphone,我是iPhone开发新手。以下代码中存在内存泄漏问题。如果有人知道为什么会这样,请帮助我 for(int i=0;i<size;i++) { NSString *CellIdentifier1; if(universalApp==2) { CellIdentifier1 = @"CustomThumbImageTableCell_iphone"; cell = [[[CustomThumbImageTableCell alloc] initWithF

我是iPhone开发新手。以下代码中存在内存泄漏问题。如果有人知道为什么会这样,请帮助我

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也分配内存…感谢您的回答。我也尝试了这个方法,但在同一个地方出现了内存泄漏。我修改了答案并留下了评论。