NSPopupButton in an NSTableCellView causing a memory leak

Environment

Xcode: 9.4.1 (or 10.0 Beta - Same result)
Swift: 4 (or 4.2 - Same Result)
Target Platform: 10.11

The Problem

I have these ridiculously simplistic NSViewController and NSTableViewCell subclasses that when combined give me very peculiar memory leaks (as reported by both the Debug Memory Graph and the Memory Leak Instrument) when I include a stock NSPopupButton in the SensorListCellView.

Code Stubs

class ViewController: NSViewController {

    @IBOutlet weak var tableSensors: NSTableView!
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override var representedObject: Any? {
        didSet {
        // Update the view, if already loaded.
        }
    }
}

extension ViewController: NSTableViewDataSource, NSTableViewDelegate {
    func numberOfRows(in tableView: NSTableView) -> Int {
        return 1
    }

    func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
    let result:SensorListCellView = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "defaultRow"), owner: self) as! SensorListCellView

        // Just fill with any data
        result.imageSensorAvailable.image       = NSImage(named: NSImage.Name("NSStatusAvailable"))
        result.imageSensorAvailable.toolTip     = "Sensor is Available & Reporting"
        result.sensorID.stringValue             = "Sensor ID"
        result.sensorDescription.stringValue    = "Sensor Description"
        result.sensorName.stringValue           = "Sensor Name"

        // Just fill with any data
        result.unitsAvailable.addItem(withTitle: "One")
        result.unitsAvailable.addItem(withTitle: "Two")
        result.unitsAvailable.addItem(withTitle: "Three")

        return result
    }
}

class SensorListCellView: NSTableCellView {
    @IBOutlet weak var unitLabel: NSTextField!
    @IBOutlet weak var imageSensorAvailable: NSImageView!
    @IBOutlet weak var sensorID: NSTextField!
    @IBOutlet weak var sensorDescription: NSTextField!
    @IBOutlet weak var sensorName: NSTextField!
    @IBOutlet weak var unitsAvailable: NSPopUpButton!
}

What's going on

Enclosed you can see my very simple storyboard (I can only attach one file). All I do is run the app, let the window appear, and hit the debug memory graph. The description for all of the leaked CFDictionary objects is:

Printing description of $0:
{
    kCUIMeasureEdgeInsetBottomLeft = "NSSize: {9, 3}";
    kCUIMeasureEdgeInsetTopRight = "NSSize: {8, 6}";
    "measure.height" = 20;
    "measure.width" = 24;
}

I just observe the four leaks regardless of the row count. There are no constraints for any of the elements in the row, the TableCellView or the TableView itself. It's just strange: When I remove the PopupButton the four leaks go away. This issue does not manifest with a ComboBox.

Any help, advice, or direction would be greatly appreciated!

Hi Mike,

It is unlikely for the issue to affect your app significantly enough to be concerned, but nevertheless you would do a great job reporting this using Apple's bug reporter together with the code and the instruments file showing the leaks.

P.S. Also keep in mind questions about SDKs rather than the language itself are more appropriate on StackOverflow or the developer forums.

Thanks, Anthony! My next stop (after this forum) was the bug reporter. I have posted the question at StackOverflow as well. I just wanted to be sure the solution wasn't obvious before I filed a bug report. I appreciate the time looking at my problem!