2012-05-28 27 views
1

當我滾動表格視圖時,儀器出現此泄漏。
我做的滾動越多,我得到的泄漏就越多,而且這發生在我的應用程序的每個表格視圖中。目標c - 滾動表格視圖時出現奇怪的泄漏

有人可以告訴我我在做什麼錯嗎?

 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

郵編。這對我們沒有什麼幫助。 – Almo

+0

貼出來,我不知道它接縫非常簡單代碼泄漏這麼多 – Eyal

+0

請發佈你的'configureCell:'代碼,併爲表代表你的頭文件。 – diegoreymendez

回答

1

我敢打賭,它發生在你的一些UIScrollViewDelegate方法,可能在scrollViewDidEndDragging:willDecelerate

嘗試運行分析來自己解決大多數顯而易見的問題。


這是一個知SDK錯誤現在,看到dev's forum

+0

是的,它看起來像一個錯誤,我試過了,當我在5.0模擬器上運行儀器時,我沒有任何泄漏,但是當我在5.1模擬器或我的設備(5.1)我得到泄漏。謝謝:) – Eyal