访问 AVAudioEngine 的某些属性或方法会在 Xcode Instruments 中导致内存泄漏。

huangapple go评论57阅读模式
英文:

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.

访问 AVAudioEngine 的某些属性或方法会在 Xcode Instruments 中导致内存泄漏。

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.访问 AVAudioEngine 的某些属性或方法会在 Xcode Instruments 中导致内存泄漏。

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.

huangapple
  • 本文由 发表于 2023年4月19日 23:54:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76056558.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定