1

I am facing one strange issue.

So I have created instance and allocated like below

var displayLink:CADisplayLink?

private func setupDisplayLink () {

    self.displayLink = CADisplayLink(target: self, selector: #selector(displayLinkDidFire(link:)))
    self.displayLink?.preferredFramesPerSecond = 30
    self.displayLink?.add(to: .main, forMode: .common)
}

Now to remove display link I have from this Answer

self.displayLink?.remove(from: .main, forMode: .common) // comment this line and view controller correctly deallocated 
self.displayLink?.invalidate()

because of line self.displayLink?.remove(from: .main, forMode: .common) my deinit method not called of view controller

In memory graph I am not able to identify the real problem. I was lucky that I have tried to comment that line and it works

enter image description here

Why that so ?

Prashant Tukadiya
  • 15,838
  • 4
  • 62
  • 98

1 Answers1

0

Stop displayLink like this:

displayLink?.invalidate()
displayLink = nil
Lu_
  • 2,577
  • 16
  • 24