2011-08-02 7 views
0

なぜこのコードはメモリリークを引き起こしていますか?この短い関数のメモリリーク

- (void)loadModalInfo 
{  
    InformationScreenViewController *infoView = [[InformationScreenViewController alloc] init]; 
    infoView.url = [[NSBundle mainBundle] URLForResource:@"NewPatientInfo" withExtension:@"html"]; // LEAKING 
    // [infoView setModalPresentationStyle:UIModalPresentationFormSheet]; 
    [infoView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal]; 
    [self presentModalViewController:infoView animated:YES]; 
    [infoView release]; 
    infoView = nil; 
} 

私はInstrumentsを使用して新しく、なぜコードが漏れているのかわかりません。 ありがとうございます。

+0

InformationScreenViewControllerのurlプロパティは何ですか? – csano

+0

私はそれがおそらく – Odys

+0

NSURLだと思いますか?奇妙な。私はそれが方法だと確信しています... – sidyll

答えて

8

あなたのInformationScreenViewController.mdealocメソッドでは、URLを解放します。

+0

ありがとう!あなたが正しい!私はdeallocメソッドでプロパティを解放するのを忘れていました... – Samui

関連する問題