【发布时间】:2011-05-24 01:00:50
【问题描述】:
我知道内存泄漏没什么大不了的,或者因为它们在 sdk 本身中而不受单个开发人员的控制,但我看到的是针对 iOS SDK 4.2 构建的 iPhone 4 上的 32KB。我无法在 3GS 上触发此功能。它是在响应用户交互时发生的(响应于打开照片库,并且泄漏似乎发生在我在照片库中时),因此它可能会迅速累积。
这是我在 iPhone 4 上看到的堆栈跟踪:
0 libSystem.B.dylib calloc
1 0x317e8363
2 0x317e9c41
3 0x318273ff
4 0x31827ea5
5 0x302ea49d
6 0x302ebe07
7 0x302eb7c3
8 0x302ebcab
9 0x303304cd
10 UIKit -[UINavigationController _startTransition:fromViewController:toViewController:]
11 UIKit -[UINavigationController _startDeferredTransitionIfNeeded]
12 UIKit -[UINavigationController viewWillLayoutSubviews]
13 UIKit -[UILayoutContainerView layoutSubviews]
14 UIKit -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
15 CoreFoundation -[NSObject(NSObject) performSelector:withObject:]
16 QuartzCore -[CALayer layoutSublayers]
17 QuartzCore CALayerLayoutIfNeeded
18 QuartzCore CA::Context::commit_transaction(CA::Transaction*)
19 QuartzCore CA::Transaction::commit()
20 QuartzCore CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*)
21 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
22 CoreFoundation __CFRunLoopDoObservers
23 CoreFoundation __CFRunLoopRun
24 CoreFoundation CFRunLoopRunSpecific
25 CoreFoundation CFRunLoopRunInMode
26 GraphicsServices GSEventRunModal
27 GraphicsServices GSEventRun
28 UIKit -[UIApplication _run]
29 UIKit UIApplicationMain
30 MyApp main /Users/david/src/MyApp/main.m:14
31 MyApp start
我在这里的任何地方都看不到我的代码,我不确定如何检查带有地址的符号。有任何想法吗?这可能与我添加的子层有关吗? (这是我在这里看到的唯一可以控制的东西。)
感谢您的帮助。
编辑:正如 GojaN 的问题所指出的(谢谢,GojaN),我完全忘了提到这在仪器中显示为:
Leaked Object # Address Size Responsible Library Responsible Frame
GeneralBlock-36864 0x4ff3000 36864 UIKit -[UINavigationController _startTransition:fromViewController:toViewController:]
【问题讨论】:
-
你怎么知道有内存泄漏?控制台中是否出现消息?您可以将控制台输出粘贴到您的问题中吗?