UITableViewDelegate memory leak
I was wondering if anyone else has notices some strange memory leaks happening in UITableViewDelegates heightForRowAtIndexPath: method. I created this simple test case to reproduce the problem:
@implementation MyView
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame])
{
UITableView *table = [[UITableView alloc] initWithFrame:frame style:UITableViewStyleGrouped];
table.dataSource = self;
table.delegate = self;
[self addSubview:table];
[table release];
}
return self;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 100;
}
// Comment this and no memory leaks should happen
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 100.0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell;
cell = [tableView dequeueReusableCellWithIdentifier:@"reuse"];
if (cell == nil) {
// Create a new cell. CGRectZero allows the cell to determine the appropriate size.
CGRect frame;
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"reuse"] autorelease];
cell.text = @"Testing";
}
return cell;
}
@end
If this view is created and added to the application window the Instument says that IndexPath is leaking memory. On the other hand if heightForRowAtIndexPath:is removed (commented out) no memory leaks happen.
So my question is has someone else also noticed this or can someone verify this. Or am I missing something very simple here. Appriciate all the help.
-Mika
MacBook, Mac OS X (10.5.5)