我很困惑,爲什麼當我調用removeFromSuperview內存分配給已移除的視圖不釋放。所以這裏是我的代碼和測試結果的一部分。 我有在uiscrollview上添加的uiscrollview和uiview。所以當我滾動我的uiscrollview我調用removefromsuperview並期待內存將被釋放。removefromsuperview不釋放內存
-(void) someFunction {
magazineContentView = [[MagazineContentView alloc] initWithFrame:CGRectMake(35 + 320 *i ,0,self.view.frame.size.width,self.view.frame.size.height)];
[_scrollView addSubview:magazineContentView];
}
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
[magazineContentView removeFromSuperview];
magazineContentView = nil;
}
magazineContentView正確刪除但內存不減少。
我沒有使用ARC。
謝謝。
您是否在使用ARC?你在哪裏檢查內存沒有減少?儀器?請在你的問題中包含所有相關的細節。 – Sid
感謝重播, 不,我不使用ARC。我正在使用標準的xcode內存報告。我添加屏幕,你可以在分配之前看到內存大小,添加視圖後添加uiview是8.5 MB,它變成了9MB,但從uiscrollview刪除此視圖後仍然保持9MB!哎呀抱歉,我無法在此刻添加屏幕,我沒有權限。 – Sergo