I used the AVPlayerDemo sample from the Apple docs and wrote my own UI on top of it to play videos selected from a UITableViewController. Now, the problem is that there\'s a mem
I had the same issue as you, but I managed to fix the memory leak by calling this on viewDidDisappear
:
self.avPlayer?.replaceCurrentItem(with: nil)
The problem was with the idleTimer. When the invalidate method is called on the idleTimer, it doesn't synchronously invalidate the timer, instead, it waits for the next tick(not sure, but does wait for some time) before invalidating and releasing it.
Now, in the meanwhile, the idleTimer reference is being set to nil. On the next tick of the timer, the reference is lost and the memory is never released, and the references propagate all the way to the ViewController and none of its objects are released.