AudioKitSynthOne icon indicating copy to clipboard operation
AudioKitSynthOne copied to clipboard

retain loops

Open wtholliday opened this issue 6 years ago • 0 comments

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.

wtholliday avatar Jun 23 '19 14:06 wtholliday