2010-06-08 92 views
0

我開始學習使用樂器,但我無法弄清楚。 我開始我的應用程序後,用戶界面顯示出來,我什麼也不做,幾秒鐘內,我可以看到檢測內存泄漏後: alt text http://img714.imageshack.us/img714/7735/instruments1.pngUIWindow#addSubview如何使內存泄漏?

當我看看第二泄漏我可以看到下面的堆棧: alt text http://img3.imageshack.us/img3/5708/instruments2.png

當我與我的代碼的單元格雙擊我可以看到它是指向下面的代碼行:

[window addSubview:newPostUIViewController.view]; 

從方法:

- (void)applicationDidFinishLaunching:(UIApplication *)application {  
//creating view controller 
newPostUIViewController = [[NewPostUIViewController alloc] initWithNibName:@"NewPostView" bundle:nil]; 
newPostUIViewController.title = @"Post it!"; 
[window addSubview:newPostUIViewController.view]; 

// Override point for customization after application launch 
[window makeKeyAndVisible]; 
} 

我想知道,這可能是泄漏的原因?我在PostItAppDelegate類的dealloc方法中釋放newPostUIViewController。

任何想法如何解釋這個?

回答

0

link text允許說這是模擬器問題,而不是代碼問題。

0

您沒有提供autoreleaserelease來平衡你的init。以防萬一你還沒有通讀它,看看memory management guide是一個很大的幫助。

+0

感謝您的建議,但是,我在PostItAppDelegate的dealloc方法中釋放了newPostUIViewController和window。我應該在其他地方叫釋放嗎? – Jakub 2010-06-08 16:26:33

+0

@Jakub你可以發佈一些更多的代碼來顯示你如何使用控制器?控制器可能有額外的保留,但不在該線上。 – slf 2010-06-09 13:10:14