1

当我滚动表格视图时,我在仪器上得到了这种泄漏。
我做的滚动越多,我得到的泄漏就越多,而且它发生在我应用程序的每个表视图中。

有人可以告诉我我在这里做错了什么吗?

       0 libsystem_c.dylib malloc
       1 libsystem_c.dylib strdup
       2 libnotify.dylib token_table_add
       3 libnotify.dylib notify_register_mach_port
       4 libnotify.dylib notify_register_dispatch
       5 CoreFoundation _CFXNotificationRegisterObserver
       6 CoreFoundation CFNotificationCenterAddObserver
       7 UIKit -[UIScrollView(Static) _startTimer:]
       8 UIKit -[UIScrollView _endPanWithEvent:]
       9 UIKit -[UIScrollView handlePan:]
      10 UIKit _UIGestureRecognizerSendActions
      11 UIKit -[UIGestureRecognizer _updateGestureWithEvent:]
      12 UIKit ___UIGestureRecognizerUpdate_block_invoke_0541
      13 UIKit _UIGestureRecognizerApplyBlocksToArray
      14 UIKit _UIGestureRecognizerUpdate
      15 UIKit _UIGestureRecognizerUpdateGesturesFromSendEvent
      16 UIKit -[UIWindow _sendGesturesForEvent:]
      17 UIKit -[UIWindow sendEvent:]
      18 UIKit -[UIApplication sendEvent:]
      19 UIKit _UIApplicationHandleEvent
      20 GraphicsServices PurpleEventCallback
      21 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__
      22 CoreFoundation __CFRunLoopDoSource1
      23 CoreFoundation __CFRunLoopRun
      24 CoreFoundation CFRunLoopRunSpecific
      25 CoreFoundation CFRunLoopRunInMode
      26 GraphicsServices GSEventRunModal
      27 UIKit UIApplicationMain
      28 MyApp 0x2bda
      29 MyApp 0x2b6f

这是表视图 viewController .m 文件:

@implementation ContactsViewController
@synthesize data = _data;
@synthesize tableView = _tableView;

- (void)dealloc
{
    [_data release];
    [_tableView release];

    [super dealloc];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg411.png"]];
    self.title = @"Contacts";


    // init tableView
    CGRect tableFrame = self.view.bounds;

    _tableView = [[UITableView alloc] initWithFrame:tableFrame style:UITableViewStylePlain];
    _tableView.backgroundColor = [UIColor clearColor];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;


    [self.view addSubview:_tableView];

    // load data
    self.data = [self loadData];
}

- (NSArray *)loadData
{
    NSArray *data = [NSArray arrayWithObjects:@"1", @"2", @"3", nil];
    return data;
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.

    self.tableView = nil;
}

#pragma mark - UITableViewDataSource

- (NSInteger)numberOfRowsInOnlySection
{
    return self.data.count;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return [self numberOfRowsInOnlySection];
}

- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath 
{
    NSString *currData = [self.data objectAtIndex:indexPath.row];

    cell.textLabel.text = currData;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier   = @"SingleCell";

    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];          
    }

    [self configureCell:cell atIndexPath:indexPath];

    return cell;  
}

@end
4

1 回答 1

1

我敢打赌它发生在你的一些UIScrollViewDelegate方法上,可能在scrollViewDidEndDragging:willDecelerate.

尝试自己运行分析以解决大多数明显的问题。


现在这是一个已知的 SDK 错误,请参阅开发者论坛

于 2012-05-28T15:39:35.880 回答