【问题标题】:Is there a leak in AVPlayers' init method?AVPlayer 的 init 方法是否存在泄漏?
【发布时间】:2012-04-13 14:10:37
【问题描述】:

我正在开发一个广泛使用 AVfoundation 的应用程序。最近我用 Instruments 做了一些泄漏检查。 “泄漏”工具在我正在实例化新 AVPlayer 的代码中的 a 点报告泄漏,如下所示:

player1 = [AVPlayer playerWithPlayerItem:playerItem1];

为了减少问题,我使用 ARC 为单视图应用程序创建了一个全新的 Xcode 项目,并放入以下行。

AVPlayer *player = [[AVPlayer alloc] init];

这会在 Instruments 中生成相同的泄漏报告。下面是堆栈跟踪。有谁知道为什么对 [[AVPlayer alloc] init] 的简单调用会导致泄漏?尽管我使用的是 ARC,但我尝试将其关闭并插入相应的 [player release];指令,它没有任何区别。这似乎与 AVPlayer 相关。

0 libsystem_c.dylib malloc
1 libsystem_c.dylib strdup
2 libnotify.dylib token_table_add
3 libnotify.dylib notify_register_check
4 AVFoundation -[AVPlayer(AVPlayerMultitaskSupport) _iapdExtendedModeIsActive]
5 AVFoundation -[AVPlayer init]
6 TestApp -[ViewController viewDidLoad] /Users/jason/Synaptic Revival/Project Field Trip/software development/TestApp/TestApp/ViewController.m:22
7 UIKit -[UIViewController view]
--- 2 frames omitted ---
10 UIKit -[UIWindow makeKeyAndVisible]
11 TestApp -[AppDelegate application:didFinishLaunchingWithOptions:] /Users/jason/Synaptic Revival/Project Field Trip/software development/TestApp/TestApp/AppDelegate.m:24
12 UIKit -[UIApplication _callInitializationDelegatesForURL:payload:suspended:]
--- 3 frames omitted ---
16 UIKit _UIApplicationHandleEvent
17 GraphicsServices PurpleEventCallback
18 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__
--- 3 frames omitted ---
22 CoreFoundation CFRunLoopRunInMode
23 UIKit -[UIApplication _run]
24 UIKit UIApplicationMain
25 TestApp main /Users/jason/software development/TestApp/TestApp/main.m:16
26 TestApp start

【问题讨论】:

  • 我到处都看到同样的泄漏,我没有使用 AVFoundation。
  • 我看到使用从 AVURLAsset 检索到的 AVPlayerItem 来初始化 AVPlayer 的行为相同。考虑让玩家成为全球性的......这真的很糟糕。

标签: memory-leaks avfoundation instruments avplayer


【解决方案1】:

Apple 确认这个 48 字节泄漏是一个已知问题,它不仅存在于 AVPlayer 中,还存在于 UIScrollView 中(我有一个应用碰巧使用了这两个组件。)

请参阅此线程以获取详细信息: Memory leak every time UIScrollView is released

这是苹果在 thead 上的答案的链接(您可能需要开发者 ID 才能登录): https://devforums.apple.com/thread/144449?start=0&tstart=0

苹果的简短引用:

这是一个已知错误,将在未来的版本中修复。 同时,虽然所有泄漏显然都是不可取的,但这不会在现实世界中引起任何用户可见的问题。用户必须滚动大约 22,000 次才能泄漏 1 兆字节的内存,因此不会影响日常使用。

似乎任何引用 notify_register_check 和 notify_register_mach_port 的组件都会导致此问题。

目前找不到明显的走动或修复。已确认此问题在 5.1 和 5.1.1 的 iOS 版本中仍然存在。希望苹果可以在 iOS 6 中解决这个问题,因为它真的很烦人而且具有破坏性。

【讨论】:

  • 您能否链接到“Apple 确认”的来源?
猜你喜欢
  • 1970-01-01
  • 2013-03-19
  • 2011-05-08
  • 1970-01-01
  • 2011-01-29
  • 2011-05-08
  • 1970-01-01
  • 2012-09-13
  • 2020-07-22
相关资源
最近更新 更多