我在我的应用程序中看到以下错误:
(4446,0xa0bc94e0) malloc: * error for object 0x1d153000: pointer being freed was not allocated * set a breakpoint in malloc_error_break to debug
这个错误是什么意思?
我试图在 TableView 中显示 2000 个地址,并且在以下代码中使用 cellForRowAtIndexPath 看到了该错误:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
obdata = [AddressBookData alloc];
obdata = [arrayLocalAddressbook objectAtIndex:indexPath.row];
// Set button Tag
cell.textLabel.text = [NSString stringWithString:obdata.lastname];
return cell;
}
// Customize the number of sections in the table view.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
//return [indexArray count];
return 1;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [arrayLocalAddressbook count];
}
这可能是什么原因造成的?
最佳答案
应用程序会提示您如何继续:在 malloc_error_break
中设置断点。到达那里后,检查应用程序的回溯。您可能会发现您过度释放了一个对象或持有一个过时的指针。
关于ios - 为什么我被告知在 malloc_error_break 中设置断点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2833358/