adamwulf / JotUI

OpenGL based drawing view built for and used by Loose Leaf for iPad
http://getlooseleaf.com/opensource/
MIT License
268 stars 28 forks source link

Memory problem with JotView #40

Open CoderMaurice opened 5 years ago

CoderMaurice commented 5 years ago

When I want to close it, [JotView dealloc] will never be executed.

CoderMaurice commented 5 years ago

adam, help!!!

adamwulf commented 5 years ago

Something must still be holding a reference to the JotView after you close it. double check that you've nil'd all references to the view in your controllers when you close it.

The best way i've found to debug memory problems like this is to use Instruments tool Allocations, and turn on reference counting in it. that'll help track down which reference is holding onto the JotView.

CoderMaurice commented 5 years ago

I ran the demo and did two things.

  1. present ViewController (JotView inside), then dismiss it
  2. Repeat the first step

the dealloc method has not been executed and the memory will keep rising.

image I modified the saveImage method in ViewController, now the ViewController can be released, but jotview won't. The problem is in the JotView

CoderMaurice commented 5 years ago

well, the displayLink in the JotView caused a reference problem

adamwulf commented 5 years ago

Great find! i've pushed up your fix for the saveImage issue you found. I also now call [jotView invalidate] whenever the view controller removeFromParentViewController. That should kill the displayLink and allow the view controller to be released whenever the controller is removed.