AudioKit / AudioKitSynthOne

AudioKit Synth One: Open-Source iOS Synthesizer App
http://audiokitpro.com/synth
MIT License
1.65k stars 214 forks source link

retain loops #95

Open wtholliday opened 5 years ago

wtholliday commented 5 years ago

In AudioKitSynthOne/Manager/Manager+callbacks.swift, retain loops are created by the callbacks. Search for callback = { in your codebase and you'll find more.

The callbacks need to be of the form

myWidget.callback = { [weak self] in
   guard let strongSelf = self else { return }
  // do stuff with strongSelf
}

This isn't a big deal for a stand-alone app (though, it's considered bad form), but if you ever want to make an AudioUnit Extension, the leaks will become an issue.

Timers are also a source of retain loops, as well as simply creating cycles between view controllers, etc.

You can use Xcode's Memory Graph Debugger to find them, though it's still not very easy.