<!--
{
  "documentType" : "article",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/responding-to-memory-warnings",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Responding to memory warnings"
}
-->

# Responding to memory warnings

Free up memory when asked to do so by the system.

## Discussion

If the system runs low on free memory and is unable to reclaim memory by terminating suspended apps, UIKit sends a low-memory warning to running apps. UIKit delivers low-memory warnings in the following ways:

- It calls the [`applicationDidReceiveMemoryWarning(_:)`](/documentation/UIKit/UIApplicationDelegate/applicationDidReceiveMemoryWarning(_:)) method of your app delegate.
- It calls the [`didReceiveMemoryWarning()`](/documentation/UIKit/UIViewController/didReceiveMemoryWarning()) method of any active [`UIViewController`](/documentation/UIKit/UIViewController) classes.
- It posts a [`didReceiveMemoryWarningNotification`](/documentation/UIKit/UIApplication/didReceiveMemoryWarningNotification) object to any registered observers.
- It delivers a warning to dispatch queues of type <doc://com.apple.documentation/documentation/Dispatch/DISPATCH_SOURCE_TYPE_MEMORYPRESSURE>.

When your app receives a low-memory warning, free up as much memory as possible, as quickly as possible. Remove references to images, media files, or any large data files that already have an on-disk representation and can be reloaded later. Remove references to any temporary objects that you no longer need. If active tasks might consume significant amounts of memory, pause dispatch queues or restrict the number of simultaneous operations that your app performs.

> Important:
> Failure to reduce your app’s memory usage may result in your app’s termination. Therefore, consider writing any unsaved data to disk as part of your cleanup efforts.

To test your app’s response to a low-memory warning, use the Simulate Memory Warning command in iOS Simulator.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)