Reputation: 3824
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];
}
Upvotes: 2
Views: 119
Reputation: 2896
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.
Upvotes: 1