Memory leak in iOS, AVPlayer is never deallocated

后端 未结 2 1620
慢半拍i
慢半拍i 2021-02-07 16:09

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

2条回答
  •  说谎
    说谎 (楼主)
    2021-02-07 16:45

    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.

提交回复
热议问题