DevPrep

All topics › Memory management

Why is there no swap in iOS? What happens under memory pressure?

Senior PRO

Why there is no swap

On iPhone anonymous memory (heap, stacks) is never paged out to flash: NAND has limited write endurance, and constant swapping on a mobile device would kill both the storage and responsiveness. Instead XNU uses the memory compressor — rarely used anonymous pages are compressed in RAM (typically 2–3×), while clean file-backed pages are simply evicted because they can be re-read from the file.

The rest of this answer, with code and interview follow-ups, is in the DevPrep app.

Read the full answer in DevPrep

Practice this before your interview

DevPrep turns these answers into one-minute challenges: what does this code print, find the bug, mock interviews. One challenge a day.

Get DevPrep on the App Store