【发布时间】: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