I have memory leaks in project. They seem related to RxSwift. I have avoided reference cycles in every possible place but leaks happen anyway. I use Instruments for leaks detection.

Could you please give any advice to investigate those leaks?
Hi, @dimalexeev ! Do you have any code snipped which do you think cause the leak?
I've updated the screenshot of the first message to localize problem.
Here is the code which seems to be the culprit.
ProgramsViewController:
func bindToInputs() {
tableView.rx.itemSelected
.map { $0.row }
.bind(to: viewModel.inputs.didSelectProgramAtIndex)
.disposed(by: bag)
}
ProgramsViewModel:
let selectedProgramIndex: Variable<Int?>
let inputs = Inputs()
init() {
self.programs = Program.samples
self.selectedProgramIndex = Variable(nil)
setOutpus()
setInputs()
}
md5-2d799cc8a738d0cf4836f14c47fe90f3
struct Inputs {
let didSelectProgramAtIndex = PublishSubject<Int>()
}
md5-2d799cc8a738d0cf4836f14c47fe90f3
func setInputs() {
inputs.didSelectProgramAtIndex.asObservable()
.bind(to: selectedProgramIndex)
.disposed(by: bag)
}
XCode 8.3.2
Simulator 10.0
Hi @dimalexeev ,
I don't see anything in the code you've pasted that would cause some leaks.
It seems to me that your claims are based on Leaks instrument.
Unfortunately proper detecting of leaks is not as simple as just opening Leaks instrument :) IMHO using raw leaks instruments (Leak Check) is pretty useless. It would either report false positive or failed to detect actual leaks.
Here is how I check for leaks on some view controller.

All Heap & Anonymous VMThen testing part
This makes sure any lazy global resources are loaded.
After that:
Mark GenerationMark GenerationThis will create two generations. You will able to check any leftover objects in bottom generation after you've returned back.
If there are some leftover objects that should have been deallocated, I would call those objects leaks.
These leaks might be caused by either your code or some internal Rx code.
Tip: Usually there are a lot of globally cached internal UIKit objects in that snapshot. That doesn't mean that those are all leaks. Going back and forth to that view controller might clean them up a bit.
Tip: You can also filter objects from your module or Rx module by using Instrument detail text field.
Tip: you can also use the following snippet to get the current number of Rx resources used. It's not as accurate as using instruments, but often far more useful.
#if DEBUG
_ = Observable<Int>.interval(1, scheduler: MainScheduler.instance)
.subscribe(onNext: { _ in
print("Resource count \(RxSwift.Resources.total)")
})
#endif
If you think that there is some part of Rx that leaks, please report us which operator do you think causes a leak. Otherwise we can't do anything about this.
According to original report this is either a report of false leak reported by instruments, or a report of real leak that hasn't been narrowed down.
In either case there isn't anything I can do based on this report.
If you narrow down a leak to some part of Rx, please open an issue for that specific Rx part.
Most helpful comment
Hi @dimalexeev ,
I don't see anything in the code you've pasted that would cause some leaks.
It seems to me that your claims are based on Leaks instrument.
Unfortunately proper detecting of leaks is not as simple as just opening Leaks instrument :) IMHO using raw leaks instruments (Leak Check) is pretty useless. It would either report false positive or failed to detect actual leaks.
Here is how I check for leaks on some view controller.
All Heap & Anonymous VMThen testing part
This makes sure any lazy global resources are loaded.
After that:
Mark GenerationMark GenerationThis will create two generations. You will able to check any leftover objects in bottom generation after you've returned back.
If there are some leftover objects that should have been deallocated, I would call those objects leaks.
These leaks might be caused by either your code or some internal Rx code.
Tip: Usually there are a lot of globally cached internal UIKit objects in that snapshot. That doesn't mean that those are all leaks. Going back and forth to that view controller might clean them up a bit.
Tip: You can also filter objects from your module or Rx module by using
Instrument detailtext field.Tip: you can also use the following snippet to get the current number of Rx resources used. It's not as accurate as using instruments, but often far more useful.
If you think that there is some part of Rx that leaks, please report us which operator do you think causes a leak. Otherwise we can't do anything about this.
According to original report this is either a report of false leak reported by instruments, or a report of real leak that hasn't been narrowed down.
In either case there isn't anything I can do based on this report.
If you narrow down a leak to some part of Rx, please open an issue for that specific Rx part.