1
我第一次使用泄漏儀器。 我正在獲得兩個泄漏在我的代碼,當我看到源代碼,那麼就說明這兩個大膽的聲明....分析ipad中的泄漏儀器問題
- (id) initWithFrame: (CGRect) frame
{
[self LoadMoviePlayer];
**self= [super initWithFrame:frame];**
if (self==[super initWithFrame:frame])
{
CAEAGLLayer* eaglLayer = (CAEAGLLayer*) self.layer;
eaglLayer.opaque = YES;
- (void) applicationDidFinishLaunching: (UIApplication*) application
{
CGRect screenBounds = [[UIScreen mainScreen] bounds];
m_window = [[UIWindow alloc] initWithFrame: screenBounds];
**m_view = [[GLView alloc] initWithFrame: screenBounds];**
[m_window addSubview: m_view];
[m_window makeKeyAndVisible];
}
不知道解決問題的下一步該怎麼做。
我在釋放m_view在dealloc函數中,我不知道爲什麼,但當我評論「self = [super initWithFrame:frame];」那麼問題就解決了。我已經檢查過self.loadmoviePlayer被調用時的自我價值和它不爲null,任何人都對我的問題有任何想法。 – LebRon
m_view的分配會將其保留計數設置爲1,窗口的addSubView會將其設置爲2.組件的dealloc會將其釋放到1,但只要您不從窗口中刪除它或執行不釋放窗口,其保留計數保持爲1. – Fuggly
此外,該loadMoviePlayer行背後的想法是:在*之後執行[super initWithFrame:] if()塊,以確切地說。如果您在尚未完全初始化的對象中創建對象的實例(這正是您在此處所做的),則行爲主要定義爲「您不想這樣做」。您已經在if()塊中設置了圖層的屬性,爲什麼不在該if()塊中加載該電影播放器呢? – Fuggly