开发者

Regarding a memory leak issue

开发者 https://www.devze.com 2023-02-08 23:42 出处:网络
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.

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

精彩评论

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

关注公众号