<!--
{
  "documentType" : "article",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/optimizing-memory-performance",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Optimizing memory performance"
}
-->

# Optimizing memory performance

Measure the impact of the 64-bit runtime on your app’s memory usage.

## Discussion

The 64-bit runtime increases the size of pointers and some scalar data, resulting in a larger memory footprint for your app. The result is increased pressure on processor caches and virtual memory, which can adversely affect performance. When developing a 64-bit app, it’s critical to profile and optimize your app’s memory usage.

### Test and profile your app

Start by creating standard tests to run against the 64-bit version of your app. With these tests, you can measure the penalty for compiling a 64-bit version of your app when compared with the 32-bit version. You can also measure improvements as you optimize your app’s memory usage.

For at least one test, use a minimal footprint — for example, one in which the app has just been opened and shows an empty document. For other tests, use a variety of data sizes, including at least one test with a very large data set. A complex app may require multiple sets of test data, each covering a subset of the app’s features.

The goal of these tests is to measure whether memory usage varies as the type or amount of data changes. If a particular kind of data causes the 64-bit version of your app to use dramatically more memory than the original 32-bit version, that’s a likely place to find opportunities for improvements.

### Use the correct function to get the virtual memory page size

Most apps don’t need to know the size of a virtual memory page, but some use it for buffer allocations and framework calls. The page size may vary between devices, so always use the `getpagesize()` function to get the size of the page.

### Ensure that your code is position independent

The 64-bit runtime environment supports only position-independent executables (PIE). By default, most apps are position independent. If some factor, such as a statically linked library or assembly code, is preventing your app from building as a PIE, you need to update your code when porting your app to the 64-bit runtime.

---

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)