iPhone内存泄漏 [英] iPhone memory leak
问题描述
我知道有些内存泄漏并没有什么大不了,或者是因为它们在sdk本身中没有受到开发人员的控制,但我看到的iPhone 4版本上针对iOS SDK 4.2的内存泄漏量为32KB。我无法在3GS上触发此功能。它是在响应用户交互时发生的(响应于打开照片库,并且当我在照片库中时发生泄漏),因此它可能会很快积累。
I know that there are memory leaks that are no big deal or are out of the individual developer's control as they are in the sdk itself, but the one I'm seeing is 32KB on the iPhone 4 build against iOS SDK 4.2. I have not been able to trigger this on a 3GS. It happens in response to user interaction (in response to opening the photo library, and the leak seems to happen while I'm in the photo library), so it could build up quickly.
这是我在iPhone 4上看到的堆栈跟踪:
Here's the stack trace I'm seeing on the 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
我在这里看不到我的代码而且我不确定是什么用地址检查符号。有任何想法吗?这可能与我正在添加的子图层有关吗? (这是我在这里看到的唯一可以控制的东西。)
I don't see my code anywhere here and I'm not sure what to do to inspect the symbols with addresses. Any ideas? Could this have something to do with the sublayers I'm adding? (That's the only thing I see here that I might have control over.)
感谢您的帮助。
编辑:正如GojaN的问题所指出的那样(谢谢,GojaN),我完全忘记提到它出现在乐器中:
As GojaN's question points out (Thanks, GojaN), I completely forgot to mention that this is showing up in instruments as:
Leaked Object # Address Size Responsible Library Responsible Frame
GeneralBlock-36864 0x4ff3000 36864 UIKit -[UINavigationController _startTransition:fromViewController:toViewController:]
推荐答案
此后不久,我的手机开始表现得非常奇怪。我删除了我的应用程序,重新安装它,并且无法再次发生这种情况。由于它之前相当一致并且易于复制,所以我将不得不将其直接用于直接成型。
Shortly after this my phone started acting very strangely. I deleted my app, reinstalled it, and haven't been able to get this to happen again. Since it was rather consistent before and easy to reproduce, I'm going to have to chalk it up to straight wonkiness.
感谢那些提供建议的人。
Thank you to those who offered advice.
这篇关于iPhone内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!