DevPrep

All topics › Memory management

How many bytes per memory access? What is a word?

Middle PRO

Word

A word is the processor's "natural" data unit: the size of a general-purpose register and of a pointer. On arm64 (all modern iPhone/iPad/Mac) a word is 8 bytes (64 bits). Hence the sizes: Int and any pointer — 8 bytes, String — 16 bytes (2 words), Array — 8 bytes (pointer to the buffer), an object header — 16 bytes (isa + refcount).

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