英文:
Accessing some of AVAudioEngine properties or methods causing a memory leak in Xcode Instruments
问题
I'm not sure wether AVAudioEngine
is internally causing some memory leaks or it is a bug of Xcode Instruments but I had a strange case where I was seeing memory leaks after launching the app.
Finally reduced the code to just calling let node = AVAudioEngine().inputNode
in AppDelegate
. Notice I'm even initialising it in place and accessing the input node. It should be created and deallocated immediately after didFinishLaunching
scope ends. When I run instruments I keep getting this memory leak for some reason.
It's really easy to reproduce just by writing this for example and running Xcode Instruments leak preset.
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
let node = AVAudioEngine().inputNode
return true
}
英文:
I'm not sure wether AVAudioEngine
is internally causing some memory leaks or it is a bug of Xcode Instruments but I had a strange case where I was seeing memory leaks after launching the app.
Finally reduced the code to just calling let node = AVAudioEngine().inputNode
in AppDelegate
. Notice I'm even initialising it in place and accessing the input node. It should be created and deallocated immediately after didFinishLaunching
scope ends. When I run instruments I keep getting this memory leak for some reason.
It's really easy to reproduce just by writing this for example and running Xcode Instruments leak preset.
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
let node = AVAudioEngine().inputNode
return true
}
答案1
得分: 0
苹果支持联系了我,看起来是预期行为。
UISoundNewDevice是一个全局对象,不应该被释放(如函数名所示:不朽)。因此,这是一个误报。
英文:
Apple support has contacted me and it appeared to be an expected behavior.
> UISoundNewDevice is a global object that is not expected to be deallocated (as the function name suggests: immortal). Thus, this is a false alarm.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论