niks
niks

Reputation: 554

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.

A popover gets displayed when clicked on a button. After the popover & its content gets allocated, application memory increases by around 2.5 MiB.

As I have 2 seperate instances of the popover in memory, it increases by around 5mb.

My problem is after popover gets dismissed its memory never gets released. Also as I have enabled ARC, I'm not able to release it manually.

Can anyone please guide me how to release memory when popover gets dismissed when used with 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];
}

Upvotes: 0

Views: 1062

Answers (2)

Jesse Rusak
Jesse Rusak

Reputation: 57188

Are you sure that the problem is the popover not being deallocated? 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.

Upvotes: 0

Paul de Lange
Paul de Lange

Reputation: 10633

I am guessing self.popOver is a strong property? It is retained by this property. When you dismiss the view, you can set this property to nil (use the delegate methods).

Upvotes: 2

Related Questions