0

*ストロング テキスト* iOS 6.1.2 で UIAlertView を表示すると、アプリで次のようなメモリ リークが発生します。

__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 は 1 つずつ何度も表示される可能性があるため、最初は UIAlertView を表示しても問題ない場合もありますが、何度か試すとメモリ リークが発生します。

4

1 に答える 1

1

交換:

[alert autorelease];

と:

[alert release];

于 2013-03-22T10:12:50.373 に答える