ios - 为什么我被告知在 malloc_error_break 中设置断点?

标签 ios ipad

我在我的应用程序中看到以下错误:

(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/

相关文章:

ios - 在 iOS 10 Cordova/Phonegap 应用程序中禁用捏合缩放

iOS 泄漏工具与事件监视器

ios - 使用社交框架Ios发布分数时出错

android - 从 Crashlytics 下载 IPA/APK

ios - 为什么UIWindow添加UIGestureRecognizer后iPad无响应?

iphone - 在 objective-c 中添加两个 double 值的问题

ios - 我必须使用标准的共享 UserDefaults 对象吗?

iphone - 视频不显示在屏幕上

ios - swift 4: UITableView setSelected 函数在 iPad 上点击两次

iphone - 针对 iPhone iPad 的 CSS 样式表不起作用