NavigationController pop ViewController 後,dealloc 不調用,Instruments 顯示內存持續增長,手動置 tableView = nil 才觸發釋放。
ARC(自動引用計數)在編譯期插入 retain/release,運行時當對象引用計數歸零時立即調用 dealloc。但「引用計數歸零」的時機取決於所有強引用持有者是否釋放,而非 pop 動作本身。
tableView.delegate = self 未聲明 weak。self 未用 __weak。view.addSubview(childVC.view) 但未調用 removeFromParentViewController。[timer invalidate] 缺失。dealloc 打斷點/日誌確認是否真正未調用(Instruments 附加可能延遲釋放,以 Memory Graph 為準)。delegate/dataSource 屬性聲明 @property (weak) id delegate;。__weak typeof(self) weakSelf = self; 並在 Block 內 strongSelf 判空。viewWillDisappear / dealloc 中:[timer invalidate]; [[NSNotificationCenter defaultCenter] removeObserver:self];。[self addChildViewController:vc]; [self.view addSubview:vc.view]; [vc didMoveToParentViewController:self]; 移除時對稱調用 willMoveToParentViewController:nil / removeFromParentViewController / removeFromSuperview。Instruments 注入監測代碼會改變對象釋放時序,且 dealloc 可能在下一個 RunLoop 觸發。以 Memory Graph 顯示對象無強引用為準,即屬正常釋放。