Introduction
Memory is an important system resource that all programs use. Programs must be loaded into memory before they can run and, while running, they allocate additional memory (both explicitly and implicitly) to store and manipulate program-level data. Making room in memory for a program’s code and data requires time and resources and therefore affect the overall performance of the system. Although you cannot avoid using memory altogether, there are ways to minimize the impact your memory usage has on the rest of the system.
This document provides background information about the memory systems of OS X and iOS and how you use them efficiently. You can use this information to tune your program’s memory usage by ensuring you are allocating the right amount of memory at the right time. This document also provides tips on how to detect memory-related performance issues in your program.
Organization of This Document
This programming topic includes the following articles:
About the Virtual Memory System introduces the terminology and provides a high-level overview of the virtual memory systems of OS X and iOS.
Tips for Allocating Memory describes the best techniques for allocating, initializing, and copying memory. It also describes the proper ways to respond to low-memory notifications in iOS.
Caching and Purgeable Memory discusses the benefits of caching, and how to avoid some of the problems that can arise from implementing caches. It also details the advantages of implementing purgeable memory into a caching system and how to successfully implement this beneficial technology.
Tracking Memory Usage describes the tools and techniques for analyzing your application’s memory usage.
Finding Memory Leaks describes the tools and techniques for finding memory leaks in your application.
Enabling the Malloc Debugging Features describes the environment variables used to enable malloc history logging. You must set some of these variables before using some of the memory analysis tools.
Viewing Virtual Memory Usage describes the tools and techniques for analyzing your application’s in-memory footprint.
Copyright © 2003, 2013 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2013-04-23