简体   繁体   English

使用ARC解除后,UIPopoverController内存不会被释放

[英]UIPopoverController memory not getting released after dismiss with ARC

I have a UIPopoverController in my project with a ViewController containing a UIDatePicker as its content. 我的项目中有一个UIPopoverController ,其中一个ViewController包含一个UIDatePicker作为其内容。

A popover gets displayed when clicked on a button. 单击按钮时会显示弹出窗口。 After the popover & its content gets allocated, application memory increases by around 2.5 MiB. 弹出窗口及其内容分配后,应用程序内存增加约2.5 MiB。

As I have 2 seperate instances of the popover in memory, it increases by around 5mb. 因为我在内存中有两个单独的弹出窗口实例,它增加了大约5mb。

My problem is after popover gets dismissed its memory never gets released. 我的问题是在popover被解雇之后它的内存永远不会被释放。 Also as I have enabled ARC, I'm not able to release it manually. 另外,由于我启用了ARC,我无法手动释放它。

Can anyone please guide me how to release memory when popover gets dismissed when used with ARC. 任何人都可以指导我如何在与ARC一起使用弹出窗口时释放内存。

Following is the code: 以下是代码:

-(IBAction)btnDateSelect:(id)sender
{

    CGRect popoverRect;
    appDelegate.objDtPicker = [[ViewDatePicker alloc]init];
    appDelegate.objDtPicker.delegate = self;

    self.popOver = [[UIPopoverController alloc]initWithContentViewController:
    appDelegate.objDtPicker]; 
    popOver.delegate = self;

    if ([sender tag] == 70) 
    {
        popoverRect = [self.view convertRect:[btnFromDate frame] 
                                    fromView:[btnFromDate superview]];
        bFromDate = TRUE;
        bToDate = FALSE;

    }
    else 
    {
        bFromDate = FALSE;
        bToDate = TRUE;
        popoverRect = [self.view convertRect:[btnToDate frame] 
                                    fromView:[btnToDate superview]];
    }


    popOver.popoverContentSize=CGSizeMake(400.0,216.0);
    [popOver presentPopoverFromRect:popoverRect inView:self.view 
           permittedArrowDirections:UIPopoverArrowDirectionDown 
                           animated:NO];
}

I am guessing self.popOver is a strong property? 我猜self.popOver是一个强大的财产? It is retained by this property. 它由这家酒店保留。 When you dismiss the view, you can set this property to nil (use the delegate methods). 关闭视图时,可以将此属性设置为nil(使用委托方法)。

Are you sure that the problem is the popover not being deallocated? 你确定问题是popover没有被释放吗? It could be that the system is caching images or other data. 可能是系统正在缓存图像或其他数据。 Does the extra memory usage go away after a memory warning? 内存警告后额外的内存使用量会消失吗? (You can simulate one of these in the simulator.) If the additional memory usage goes away after a memory warning, it's probably not a problem. (您可以在模拟器中模拟其中一个。)如果在内存警告后额外的内存使用量消失,则可能不是问题。

You might try running your application with the "Allocations" or "Leaks" instrument, which would let you find out if the popover is actually being deallocated, and what is actually taking up your 5 MB. 您可以尝试使用“Allocations”或“Leaks”工具运行您的应用程序,这样可以让您了解弹出窗口是否实际被释放,以及实际占用5 MB的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM