AbeAndrewsDEV
AbeAndrewsDEV

Reputation: 23

Memory Warning in Xcode - What does one do in didReceiveMemoryWarning?

I have asked this before but I think my question was not understood, so here goes again:

We do not handle memory anymore, since ARC does that. We cannot even invoke memory release commands etc.. So what CAN one do programmatically at RUN TIME to address a memory warning issue if the delegate receives the memory warning notification?

I do NOT want to know how to fix my code!!! Code cannot fix itself at run time.

Assuming I have coded correctly, BUT still receive a memory warning, what can be done ..

ie Can you give an example of what to code into the

- (void)didReceiveMemoryWarning
{
     [super didReceiveMemoryWarning];
          // Release any cached data, images, etc that aren't in use.
     ;
}

method?

Upvotes: 2

Views: 3388

Answers (2)

Santi Pérez
Santi Pérez

Reputation: 370

Maybe too naive, but what I do is log present values of variables so I can track down errors or what may be causing the warning.

Upvotes: 0

justin
justin

Reputation: 104698

Of course you still have control over memory. You're just operating at a higher abstraction level with ARC.

You can use: object = nil to clear a strong reference. When all strong references are cleared, the object is deallocated.

If you are familiar with manual reference counting:

object = nil; << ARC

is like this when doing your own reference counting:

[object release], object = nil;

Upvotes: 2

Related Questions