iPhone:OpenAL 和AudioToolbox 泄漏

发布于 2024-09-25 12:25:42 字数 4309 浏览 2 评论 0原文

我与 OpenAL 合作在我的应用程序中播放声音。当我使用 Instruments 工具测试它时,它发现了泄漏:
泄漏对象 = GeneralBlock-512
大小 = 512 字节
负责库 = AudioToolbox
Responsible Frame = AU3DMixerEmbeddedInputElement::Initialize()

堆栈跟踪:

   0 libSystem.B.dylib malloc
   1 libstdc++.6.dylib operator new(unsigned long)
   2 libstdc++.6.dylib operator new[](unsigned long)
   3 AudioToolbox AU3DMixerEmbeddedInputElement::Initialize()
   4 AudioToolbox AU3DMixerEmbedded::SetProperty(unsigned long, unsigned long, unsigned long, void const*, unsigned long)
   5 AudioToolbox AUBase::DispatchSetProperty(unsigned long, unsigned long, unsigned long, void const*, unsigned long)
   6 AudioToolbox AUMethodSetProperty(void*, unsigned long, unsigned long, unsigned long, void const*, unsigned long)
   7 OpenAL OALContext::InitializeMixer(unsigned long)
   8 OpenAL OALContext::OALContext(unsigned long, OALDevice*, int const*, unsigned long&, double&)
   9 OpenAL alcCreateContext
  10 myApp -[myAudioManager initOpenAL] /Users/kpower/Documents/projects/myApp/Classes/myAudioManager.m:197
  11 myApp -[myAudioManager init] /Users/kpower/Documents/projects/myApp/Classes/myAudioManager.m:83
  12 myApp +[myAudioManager sharedInstance] /Users/kpower/Documents/projects/myApp/Classes/myAudioManager.m:316
  13 myApp -[myMainMenu viewDidLoad] /Users/kpower/Documents/projects/myApp/Classes/myMainMenu.m:46
  14 UIKit -[UIViewController view]
  15 UIKit -[UIViewController contentScrollView]
  16 UIKit -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:]
  17 UIKit -[UINavigationController _layoutViewController:]
  18 UIKit -[UINavigationController _startTransition:fromViewController:toViewController:]
  19 UIKit -[UINavigationController _startDeferredTransitionIfNeeded]
  20 UIKit -[UINavigationController viewWillLayoutSubviews]
  21 UIKit -[UILayoutContainerView layoutSubviews]
  22 UIKit -[UIView(CALayerDelegate) _layoutSublayersOfLayer:]
  23 CoreFoundation -[NSObject(NSObject) performSelector:withObject:]
  24 QuartzCore -[CALayer layoutSublayers]
  25 QuartzCore CALayerLayoutIfNeeded
  26 QuartzCore -[CALayer layoutIfNeeded]
  27 UIKit -[UIView(Hierarchy) layoutIfNeeded]
  28 UIKit -[UIViewController window:willAnimateRotationToInterfaceOrientation:duration:]
  29 UIKit -[UIWindow _setRotatableClient:toOrientation:duration:force:]
  30 UIKit -[UIWindow _setRotatableViewOrientation:duration:force:]
  31 UIKit -[UIWindow _updateToInterfaceOrientation:duration:force:]
  32 UIKit -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:]
  33 UIKit -[UIWindow setDelegate:]
  34 UIKit -[UIViewController _tryBecomeRootViewControllerInWindow:]
  35 UIKit -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]
  36 UIKit -[UINavigationController viewDidMoveToWindow:shouldAppearOrDisappear:]
  37 UIKit -[UIView(Internal) _didMoveFromWindow:toWindow:]
  38 UIKit -[UIView(Hierarchy) _postMovedFromSuperview:]
  39 UIKit -[UIView(Internal) _addSubview:positioned:relativeTo:]
  40 UIKit -[UIView(Hierarchy) addSubview:]
  41 myApp -[myAppAppDelegate applicationDidFinishLaunching:] /Users/kpower/Documents/projects/myApp/Classes/myAppAppDelegate.m:19
  42 UIKit -[UIApplication _callInitializationDelegatesForURL:payload:suspended:]
  43 UIKit -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:]
  44 UIKit -[UIApplication handleEvent:withNewEvent:]
  45 UIKit -[UIApplication sendEvent:]
  46 UIKit _UIApplicationHandleEvent
  47 GraphicsServices PurpleEventCallback
  48 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__
  49 CoreFoundation __CFRunLoopDoSource1
  50 CoreFoundation __CFRunLoopRun
  51 CoreFoundation CFRunLoopRunSpecific
  52 CoreFoundation CFRunLoopRunInMode
  53 UIKit -[UIApplication _run]
  54 UIKit UIApplicationMain
  55 myApp main /Users/kpower/Documents/projects/myApp/Classes/../main.m:13
  56 myApp start

initOpenAL 中的代码(第 197 行附近):

device = alcOpenDevice(NULL);
if (NULL == device) return NO;

context = alcCreateContext(device, 0);  // line 197 - tried using NULL instead of 0 - same result
if (NULL == context) return NO;

alcMakeContextCurrent(context);  

这并不重要(它不会不时重复,消耗内存),但如何才能我修复它?

I work with OpenAL to play sounds in my app. When I test it using Instruments tool, it finds a leak:
LeakedObject = GeneralBlock-512
Size = 512 Bytes
Responsible Library = AudioToolbox
Responsible Frame = AU3DMixerEmbeddedInputElement::Initialize()

Stack trace:

   0 libSystem.B.dylib malloc
   1 libstdc++.6.dylib operator new(unsigned long)
   2 libstdc++.6.dylib operator new[](unsigned long)
   3 AudioToolbox AU3DMixerEmbeddedInputElement::Initialize()
   4 AudioToolbox AU3DMixerEmbedded::SetProperty(unsigned long, unsigned long, unsigned long, void const*, unsigned long)
   5 AudioToolbox AUBase::DispatchSetProperty(unsigned long, unsigned long, unsigned long, void const*, unsigned long)
   6 AudioToolbox AUMethodSetProperty(void*, unsigned long, unsigned long, unsigned long, void const*, unsigned long)
   7 OpenAL OALContext::InitializeMixer(unsigned long)
   8 OpenAL OALContext::OALContext(unsigned long, OALDevice*, int const*, unsigned long&, double&)
   9 OpenAL alcCreateContext
  10 myApp -[myAudioManager initOpenAL] /Users/kpower/Documents/projects/myApp/Classes/myAudioManager.m:197
  11 myApp -[myAudioManager init] /Users/kpower/Documents/projects/myApp/Classes/myAudioManager.m:83
  12 myApp +[myAudioManager sharedInstance] /Users/kpower/Documents/projects/myApp/Classes/myAudioManager.m:316
  13 myApp -[myMainMenu viewDidLoad] /Users/kpower/Documents/projects/myApp/Classes/myMainMenu.m:46
  14 UIKit -[UIViewController view]
  15 UIKit -[UIViewController contentScrollView]
  16 UIKit -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:]
  17 UIKit -[UINavigationController _layoutViewController:]
  18 UIKit -[UINavigationController _startTransition:fromViewController:toViewController:]
  19 UIKit -[UINavigationController _startDeferredTransitionIfNeeded]
  20 UIKit -[UINavigationController viewWillLayoutSubviews]
  21 UIKit -[UILayoutContainerView layoutSubviews]
  22 UIKit -[UIView(CALayerDelegate) _layoutSublayersOfLayer:]
  23 CoreFoundation -[NSObject(NSObject) performSelector:withObject:]
  24 QuartzCore -[CALayer layoutSublayers]
  25 QuartzCore CALayerLayoutIfNeeded
  26 QuartzCore -[CALayer layoutIfNeeded]
  27 UIKit -[UIView(Hierarchy) layoutIfNeeded]
  28 UIKit -[UIViewController window:willAnimateRotationToInterfaceOrientation:duration:]
  29 UIKit -[UIWindow _setRotatableClient:toOrientation:duration:force:]
  30 UIKit -[UIWindow _setRotatableViewOrientation:duration:force:]
  31 UIKit -[UIWindow _updateToInterfaceOrientation:duration:force:]
  32 UIKit -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:]
  33 UIKit -[UIWindow setDelegate:]
  34 UIKit -[UIViewController _tryBecomeRootViewControllerInWindow:]
  35 UIKit -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]
  36 UIKit -[UINavigationController viewDidMoveToWindow:shouldAppearOrDisappear:]
  37 UIKit -[UIView(Internal) _didMoveFromWindow:toWindow:]
  38 UIKit -[UIView(Hierarchy) _postMovedFromSuperview:]
  39 UIKit -[UIView(Internal) _addSubview:positioned:relativeTo:]
  40 UIKit -[UIView(Hierarchy) addSubview:]
  41 myApp -[myAppAppDelegate applicationDidFinishLaunching:] /Users/kpower/Documents/projects/myApp/Classes/myAppAppDelegate.m:19
  42 UIKit -[UIApplication _callInitializationDelegatesForURL:payload:suspended:]
  43 UIKit -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:]
  44 UIKit -[UIApplication handleEvent:withNewEvent:]
  45 UIKit -[UIApplication sendEvent:]
  46 UIKit _UIApplicationHandleEvent
  47 GraphicsServices PurpleEventCallback
  48 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__
  49 CoreFoundation __CFRunLoopDoSource1
  50 CoreFoundation __CFRunLoopRun
  51 CoreFoundation CFRunLoopRunSpecific
  52 CoreFoundation CFRunLoopRunInMode
  53 UIKit -[UIApplication _run]
  54 UIKit UIApplicationMain
  55 myApp main /Users/kpower/Documents/projects/myApp/Classes/../main.m:13
  56 myApp start

Code in initOpenAL (near the line 197):

device = alcOpenDevice(NULL);
if (NULL == device) return NO;

context = alcCreateContext(device, 0);  // line 197 - tried using NULL instead of 0 - same result
if (NULL == context) return NO;

alcMakeContextCurrent(context);  

It's not critical (it doesn't repeat from time to time, consuming memory), but how can I fix it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一袭白衣梦中忆 2024-10-02 12:25:42

我认为这是图书馆本身的问题,因为我也遇到了问题,其他人也报告了同样的问题。将此归咎于苹果。希望他们能尽快解决这个问题。

I think this is a problem with the library itself as I also get problems and others report the same. Blame Apple for this. Hopefully they will sort this out soon.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文