0

I have simple one UIViewViewController app with a UILabel outlet. I have one MutableProperty<String?> that I bind to label.reactive.text this causes 57 memory leaks. Does binding two mutable properties always leak memory, if so why?

class ViewController: UIViewController {

    @IBOutlet weak var testLabel: UILabel!
    let testText: MutableProperty<String?> = MutableProperty("")

    override func viewDidLoad() {
        super.viewDidLoad()
        let signal = textSignal()
        testText <~ signal
        testLabel.reactive.text <~ testText

        DispatchQueue.main.asyncAfter(deadline: .now() + 6) {
            UIApplication.shared.keyWindow?.rootViewController = UIViewController()
        }
    }

    func textSignal() -> SignalProducer<String, NoError> {
        return SignalProducer<String, NoError>{ (sink: Observer, disposable: Disposable) in
            DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
                sink.send(value: "Hello world")
                print("sink Hello world")
            }
            DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
                sink.send(value: "Wabbu Labbu dub dub")
                print("sink Wabbu Labbu dub dub")
            }
            DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
                sink.sendCompleted()
                print("sink compeleted")
            }
        }
    }
}
Mo Abdul-Hameed
  • 6,030
  • 2
  • 23
  • 36
stringCode
  • 2,274
  • 1
  • 23
  • 32
  • 2
    I know some changes were made in ReactiveSwift 2.0 to prevent false positives in leak reporting by memory debuggers ([see here](https://github.com/ReactiveCocoa/ReactiveSwift/blob/master/CHANGELOG.md#modified-signal-lifetime-semantics-355)). Are you on 1.x? – jjoelson Aug 25 '17 at 14:50
  • I don't think it was false positive, but upgrading to 2.0 does seem to solve the issue, thank you ! – stringCode Aug 28 '17 at 14:10

0 Answers0