Short description of the issue:
Xcode 10.2, when configured to detect memory leaks (Malloc scribble, Malloc Stack -Live Only) is reporting a leak in AtomicInt/BinaryDisposable/DisposeBag. Just noticed this after upgrading to the latest xcode/rxswift combo. It's happening in a fairly generic viewcontroller that defines a dispose bag as a class let and sets up subscriptions in viewDidLoad(). There's nothing particularly special going on in this view controller so I'm fairly certain the issue is with Rx somehow.
Expected outcome:
No leaks
What actually happens:
Leaks
Self contained code example that reproduces the issue:
override func viewDidLoad() {
super.viewDidLoad()
someObservable
.map { $0.someObjectProperty }
.filter { !$0.isPropertySomeThingB && !$0.isPropertySomeThingB }
.distinctUntilChanged()
.observeOn(MainScheduler.instance)
.subscribe(onNext: { [weak self] value in self?.localFunction(value: value) })
.disposed(by: disposeBag)
}
RxSwift/RxCocoa/RxBlocking/RxTest version/commit
4.5.0
Platform/Environment
How easy is to reproduce? (chances of successful reproduce after running the self contained code)
Xcode version:
10.2
Installation method:
I have multiple versions of Xcode installed:
(so we can know if this is a potential cause of your issue)
Level of RxSwift knowledge:
(this is so we can understand your level of knowledge
and formulate the response in an appropriate manner)

Hi @RamblinWreck77 ,
It is completely possible that we have leaks somewhere in AtomicInt but you haven't provided any proofs that we have them.
Automatic memory leaks detector is completely useless. The correct way to detect leaks is:
This is how you detect a memory leak by definition.
Automatic leak detector can't possibly know when should some object be deallocated. I'm not even sure why does Apple even ship it.
Right there on your screenshot there is a DisposeBag which holds a reference to BinaryDisposable and AtomicInts, which is normal.
@kzaher Interesting. Popping the parent VC definitely resulted in the "leak" disappearing. I've never seen a false-positive in my project/RxSwift before this update so I thought I'd share. Thanks!
Most helpful comment
Hi @RamblinWreck77 ,
It is completely possible that we have leaks somewhere in
AtomicIntbut you haven't provided any proofs that we have them.Automatic memory leaks detector is completely useless. The correct way to detect leaks is:
This is how you detect a memory leak by definition.
Automatic leak detector can't possibly know when should some object be deallocated. I'm not even sure why does Apple even ship it.
Right there on your screenshot there is a
DisposeBagwhich holds a reference toBinaryDisposableandAtomicInts, which is normal.