UITab memory leak

I have the following view hierarchy in my app: [UINavigationController] -> [MainViewController] -> [MyTabBarController] -> [DashboardViewController]

In my MainViewController I have a button that pushes the MyTabBarController onto the navigation controllers stack. In the tab bar controller I only have one tab in this example showing the DashboardViewController.

That all works fine, and when I tap the back button on MyTabBarController, everything works fine and the MainViewController is shown again. The UI works exactly how I want it, but when I load up the 'Debug Memory Graph' view, I can see that my DashboardViewController is still in memory and it seems the UITab has a reference to it. The MyTabBarController is NOT in memory anymore.

MyTabBarController is very simple:

class MyTabBarController: UITabBarController {

  override func viewDidLoad() {
    super.viewDidLoad()
    
    self.mode = .tabSidebar
    
    var allTabs:[UITab] = []
    
    let mainTab = UITab(title: "Dashboard",
                        image: UIImage(systemName: "chart.pie"),
                   identifier: "dashboard",
       viewControllerProvider: { _ in
                                 return UINavigationController(rootViewController: DashboardViewController())
                               })
    allTabs.append(mainTab)

    setTabs(allTabs, animated: false)
  }
}

And the DashboardViewController is empty:

class DashboardViewController: UIViewController {
}

The only reason I created as a seperate class in this example is so I can easily see if it's visible in the memory debug view.

I have uploaded the simple sample app to GitHub: https://github.com/fwaddle/TabbarMemoryLeakCheck

Anyone have any suggestions?

Here is a screen grab of the memory debug view showing the UITab having a reference to the DashboardViewController even though MyTabBarController has been dealloc'd:

Hello Moff,

Thank you for the focused Xcode project and screenshot. Unfortunately, I am not yet able to replicate this issue. Could you please provide which version of Xcode you are using and which iOS version and device of the simulator you are running on?

Thank you for your patience,

Richard Yeh  Developer Technical Support

Hi Richard, Thanks for the quick response. I am on Xcode 26.2, and running iPadOS 26.2. Interestingly enough, it works fine on an iPhone simulator, but not the iPad.

UITab memory leak
 
 
Q