开发者

Regarding a memory leak issue

I am new to iPhone development. I have a memory leak issue in the following code. If anyone knows why it's happening please help me.

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];  

}


Moreover, use auto release pool,

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];
}

And check imgViewArray, as you know, the retain count of an object added to an NSMutableArray is increased by 1.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜