0

When receiving a memory warning, those delegate methods get called:

In UIViewController:

func didReceiveMemoryWarning()

Sent to the view controller when the app receives a memory warning.

In AppDelegate:

optional func applicationDidReceiveMemoryWarning(_ application: UIApplication)

Tells the delegate when the app receives a memory warning from the system. [...] Try to clean up as much memory as possible. next step is to terminate app

My question, as a newbie, is how can I "clean up as much memory as possible"? Especially if there are some leaks in my app.

Thank you for your help

John DoeDoe
  • 133
  • 1
  • 7

1 Answers1

0

If you’ve have material leaks, you should simply fix those. They’ll be a persistent source of problems as you move forward. The “debug memory graph” tool is really useful when diagnosing those issues.

In answer to the question, when it says “clean up as much memory as possible” it means that you should release anything that can be readily re-retrieved or re-constructed. For example, maybe you downloaded images and have kept them in memory. You might remove those images from memory and re-retrieve them should you need them again.

Rob
  • 415,655
  • 72
  • 787
  • 1,044