【发布时间】:2011-05-17 06:40:05
【问题描述】:
假设您从头开始创建一个新的 iOS 应用程序,只有一个窗口。 然后你把这段代码放在 appDelegate 应用程序的 didFinishLaunching 方法中:
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中,完全没有问题。
当然,在实际应用中,UIalertView 是通过按钮触发的,但结果是一样的。
有什么问题? UIAlertView 在 iOS4 之前是否存在错误?
【问题讨论】:
-
是什么让您认为它实际上泄漏了?内存将一直在使用,直到您关闭它,因此请确保测试正确的间隔。
-
Leaks 比这更聪明。它检测实际的孤立对象。
标签: iphone memory ios4 memory-leaks uialertview