翻页时,UIPageViewController不释放内存

时间:2015-08-04 15:00:40

标签: ios objective-c memory memory-management automatic-ref-counting

我正在开发一个电子书项目,我也在使用ARC,但是,当我在模拟器中翻页时,我的内存增长很快,当我完成翻转时,它接近200MB。似乎记忆没有被释放,但是不是ARC的用途?我删除了我的NSTimer,并将所有人一起委托,看看这是否是罪魁祸首,但无济于事。好像我在某个地方有一个保留周期,我似乎无法找到它。我也没有使用块......有什么想法吗?

编辑:这是一个UIPageViewController应用程序

我替换了以下代码

        - (DataViewController *)viewControllerAtIndex:(NSUInteger)index storyboard:(UIStoryboard *)storyboard {
            // Return the data view controller for the given index.
            if (([self.pageData count] == 0) || (index >= [self.pageData count])) {
                return nil;
            }
            // Create a new view controller and pass suitable data.
            DataViewController *dataViewController = [storyboard instantiateViewControllerWithIdentifier:@"DataViewController"];
        with
        - (DataViewController *)viewControllerAtIndex:(NSUInteger)index storyboard:(UIStoryboard *)storyboard {
            // Return the data view controller for the given index.
            if (([self.pageData count] == 0) || (index >= [self.pageData count])) {
                return nil;
            }
            // Create a new view controller and pass suitable data.
            DataViewController *dataViewController = [storyboard instantiateViewControllerWithIdentifier:self.pageData[index]];

其中self.pageData [index]是故事板中viewcontroller的id。我希望pageViewController在请求下一个viewController

时释放这个viewController

1 个答案:

答案 0 :(得分:0)

经过数小时的研究后,UIPageViewController似乎故意保留对所有视图控制器的永久引用,并且从未发布它们(即使使用ARC) 解决方法是在切换页面时手动调用[self setView:nil]。