iOS4(UIAlertView)为什么这段代码导致内存泄漏? [英] iOS4 (UIAlertView) why this code causes memory leaks?

查看:88
本文介绍了iOS4(UIAlertView)为什么这段代码导致内存泄漏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设您从头开始创建一个新的iOS应用程序,只需一个窗口。
然后你将这段代码放入appDelegate应用程序didFinishLaunching方法:

suppose you create a new iOS app from scratch, with just one single window. then you put this code in the appDelegate application didFinishLaunching method :

UIAlertView *myAlert = [[UIAlertView alloc] 
  initWithTitle:@"alert"                                   
  message:@"message"
  delegate:nil /* same problem with 'delegate:self' */
  cancelButtonTitle:nil 
  otherButtonTitles:@"Ok", nil];
[myAlert show];
[myAlert release];

在模拟器4.1中构建和运行,附加工具,并且...
这导致每个时间内存泄漏。在leopard上的模拟器3.1.2中
,完全没问题。

build and run in simulator 4.1, attach instrument, and... this causes each time a memory leak. in simulator 3.1.2 on leopard, no problem at all.

当然,在一个真实的应用程序中,UIalertView被一个按钮驱动,但是结果是一样的。

Of course, in a real app, the UIalertView is trigerred by a button, but the result is identical.

有什么问题?
是UIAlertView越野车直到iOS4?

What is the problem ? is UIAlertView buggy until iOS4 ?

推荐答案

不要检查模拟器中的泄漏。它没有相同的内存模型,因此报告泄漏时没有。

Don't check for leaks in a simulator. It doesn't have the same memory model so reports leaks when there aren't any.

在真实设备上进行测试,如果泄漏仍然存在,请将其报告为Apple的一个错误:)

Test on a real device and if the leak is still there, report it as a bug to Apple :)

这篇关于iOS4(UIAlertView)为什么这段代码导致内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆