* 强文 *在iOS 6.1.2中显示UIAlertView时,app会出现如下内存泄漏:
__NSDictionaryM 1 0x1e5c6000 32 Bytes TextInput __92-[TIResourcePathManager fetchAssetsWithNames:forInputModes:updatingDictionary:continuation:]_block_invoke_0
Malloc 16 Bytes 1 0x1e5d5320 16 Bytes TextInput __92-[TIResourcePathManager fetchAssetsWithNames:forInputModes:updatingDictionary:continuation:]_block_invoke_0
代码如下,
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if (indexPath.row == 1 && indexPath.section == 1) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Test" message:nil delegate:nil cancelButtonTitle:@"cancel" otherButtonTitles:@"ok", nil];
[alert show];
[alert autorelease];
}
为什么?
PS。也许我忘了说这个UIAlertView可能会逐个显示多次,所以有时第一次显示UIAlertView会好的,但是当我多次尝试时,会发生内存泄漏。
答案 0 :(得分:1)
替换:
[alert autorelease];
使用:
[alert release];