Skip to content

dyld Shared Cache on macOS: How It Works

Where the dyld shared cache lives on each macOS version (it moved to the Cryptex in Ventura), how to extract dylibs from it, and why every process maps it.

Published 9 min read
Shared cache in a process address spaceA typical macOS process address space. The dyld shared cache occupies the largest virtual region, shared across every process; the app's own segments and heap are per-process.ONE PROCESS'S VIRTUAL ADDRESS SPACEnull guard page0x0…0x1000main binary __TEXT + __DATA0x100000000…0x100100000dyld shared cache (≈1.5 GB)0x180000000…0x2A0000000SHARED · same physical pages across every processthird-party frameworks (per-process)0x2A0000000…0x2A0040000malloc heap (anon, zero-fill, COW)anonstacks per thread0x16f000000…PHYSICAL MEMORY BACKINGShared cache backingOne copy in physical RAMMapped into every processSame physical pagesdyld_shared_cache_arm64e≈ 3-5 GB on disk≈ 1-2 GB mapped per processPer-process backingMain binary, third-partyframeworks, heap, stack— distinct physical pagesper processWhy this mattersActivity Monitor "Virtual" includes shared."Real Memory" counts shared once.The huge VSize number is mostly free.

Open Activity Monitor and look at the Virtual Memory column for any process. Even a tiny one — echo, cat, a hello-world program — sits around 1 GB of virtual size. The number doesn't change much between huge apps and trivial ones. The real number that scales with the app is Real Memory (resident set), and that's much smaller.

The explanation is the dyld shared cache — a single giant pre-linked file containing every system dylib, mapped into every process on the system at the same virtual address. The cache is a data file that dyld consumes; if you are looking for what dyld itself is (the dynamic linker that runs before main), start with what dyld is. This article walks how the cache works, where it lives on each macOS version, what happened to update_dyld_shared_cache, and how to pull dylibs back out of it.

What's in the shared cache

On current macOS the cache lives in the OS Cryptex on the Preboot volume (the per-version table is further down):

/System/Volumes/Preboot/Cryptexes/OS/System/Library/dyld/dyld_shared_cache_<arch>

Together with its subcache files it is several GB on Apple Silicon. It contains:

  • Every Apple-supplied .dylib in the system: libSystem, libobjc, Foundation, AppKit, UIKit, CoreFoundation, every Metal library, every Core ML library, every PDFKit / WebKit / MapKit framework — hundreds of them.
  • The pre-resolved relocation chains between them.
  • A hash table for fast symbol lookup.
  • A minified version of dyld itself (the loader runs from here too).

Building the cache is a long, expensive offline process. Up to macOS 10.15 it ran on your Mac after installs and updates; since macOS 11 Apple builds it once per OS build and ships it signed, inside the update. The result: dyld can map every system dylib into a new process with one mmap call instead of hundreds of individual dlopens.

apple-oss-distributions/dylddyld/main.cppdyld's entry point — where the shared cache is mapped into a new process.View on GitHub(line —) apple-oss-distributions/dyldcache_builderThe offline cache builder — runs at OS install / update.View on GitHub(line —)

How it's mapped

When a new process starts, the kernel maps the shared cache into the new task's address space at a known address (a file-backed shared mapping; mmap on XNU explains the vm_map_entry / vm_object machinery underneath):

  • The cache occupies a contiguous virtual range of around 1-2 GB.
  • The mapping is shared across every process — the same physical pages back it everywhere.
  • Permissions: text/code pages are read+execute, data pages are read+write (with COW so writes from one process don't affect others), const data is read-only.

Every process on the system maps the exact same virtual address range to the exact same physical pages for the cache. This is huge:

  • Physical memory savings: every dylib is in RAM once, not per-process.
  • L1/L2/L3 cache hits: dylib code executes from the same physical lines across processes; once one process warms up objc_msgSend in the cache, every process benefits.
  • Page table sharing: the page-table entries for the cache region are identical across tasks; the kernel can share entire L3 page tables.

The performance win is substantial — process startup is dominated by mapping the shared cache, which is one mmap instead of hundreds of individual dylib opens.

Address-space slide (ASLR)

The cache's base address is randomized at boot (cache-level ASLR). Every process on the system maps it at the same address — but that address is different across boots, frustrating attackers who'd otherwise know exactly where objc_msgSend lives in any process's address space.

The slide is small (a few bits of randomness) but enough to defeat static gadget-address-based exploitation. Combined with per-process ASLR for the app's own code, the address layout is hard to predict.

apple-oss-distributions/dylddyld_shared_cacheThe shared-cache header and slide handling.View on GitHub(line —)

What's NOT in the cache

  • Third-party frameworks — apps that bundle their own copies of Sparkle, Crashlytics, Swift libraries, etc. Each app pays its own cost for these.
  • App's own code — the binary itself plus its bundled frameworks. These are mapped per-process.
  • Swift runtime libraries when not in the cache — older macOS versions had Swift's runtime outside the cache; modern versions include it.
  • DriverKit dext frameworks — separate cache for those.

This is why a Swift app with many third-party dependencies has higher startup cost than an objc-only app — the shared cache benefit only applies to system frameworks.

How dyld uses it

When dyld starts a process:

  1. The kernel has already mapped the cache (and dyld itself, which lives in the cache).
  2. dyld reads the main executable's LC_LOAD_DYLIB commands.
  3. For each declared dependency, dyld checks the cache's symbol table first.
  4. If the dependency is in the cache → skip — it's already mapped and resolved.
  5. If not in the cache → dlopen it individually.
  6. Resolve the main executable's external symbols against the loaded dylibs (cache + per-process).
  7. Run static initializers in dependency order.
  8. Call main.

For a typical app, almost all dependencies are in the cache. The expensive parts (loading, linking) were done offline at OS install; per-process startup is mostly "map binary + run initializers."

apple-oss-distributions/dylddyld/PrebuiltLoader.cppPre-built loader objects in the cache — what makes dyld's job O(1) per dylib for cached ones.View on GitHub(line —)

Inspecting the cache

A few tools:

  • dyld_info -dependents /path/to/app — list a binary's dependencies.
  • dyld_info -all_dyld_cache -linked_dylibs — run a dyld_info query against every dylib in the cache your process is using, without extracting anything.
  • vmmap <pid> — dump a running process's address space; the shared cache shows up as a giant __LINKEDIT/__DATA/__TEXT region around a specific address.

A running process's vmmap output shows:

SUBMAP                  10000000-1d0000000 [1.5G] r-x/r-x SM=COW shared cache

That's the shared cache region. Read-execute, copy-on-write semantics on writable pages, mapped-into-every-process.

Why the shared cache is replaced by upgrades

The cache bakes in the exact layout of every system dylib, so any OS update that changes one library needs a new cache. Since macOS 11 the update simply ships the new, already-built dyld_shared_cache_* files; on macOS 13 and later a Rapid Security Response can replace the whole OS Cryptex, cache included, without touching the sealed system volume. After the reboot every process maps the new cache.

update_dyld_shared_cache and update_dyld_sim_shared_cache

update_dyld_shared_cache is the tool that used to rebuild the cache on the Mac itself. Through macOS 10.15 the cache lived in /private/var/db/dyld/, and installers (or an admin, with sudo update_dyld_shared_cache -force) ran it whenever a system dylib changed. That model ended with macOS 11: the system volume became a sealed, signed snapshot, so nothing on the machine may rewrite the cache, and Apple ships it pre-built instead. In the current open-source dyld the tool is literally a stub whose main returns 0:

apple-oss-distributions/dyldcache_builder/update_dyld_shared_cache.cppThe modern update_dyld_shared_cache: an empty main() that returns 0. Kept only so old scripts don't fail.View on GitHub(line —)

So if a guide tells you to run update_dyld_shared_cache to fix a slow or broken Mac on macOS 11 or later, it does nothing. Old installer scripts that still call it keep working only because the no-op exits successfully.

update_dyld_sim_shared_cache is still real. It builds the dyld shared cache for an iOS, watchOS or tvOS Simulator runtime from that runtime's files (-root <runtime root>, -cache_dir <output>, -arch, -force). Xcode runs it in the background after you install or update a Simulator runtime, which is why it can show up in Activity Monitor using a lot of CPU for several minutes after an Xcode update. It rebuilds only when a dylib in the runtime has changed; letting it finish makes the first Simulator boot fast.

apple-oss-distributions/dyldcache_builder/update_dyld_sim_shared_cache.cppThe Simulator cache builder: argument parsing (-root, -cache_dir, -arch, -force) and the 'rebuilding dyld cache because dylib changed' check.View on GitHub(line —)

Where the cache lives by macOS version and how to extract it

macOSCache locationNotes
10.x (up to 10.15)/private/var/db/dyld/Built on the Mac by update_dyld_shared_cache; the individual dylibs were also on disk.
11 Big Sur, 12 Monterey/System/Library/dyld/On the sealed system volume. Individual system dylibs removed from disk. macOS 12 splits the cache into several subcache files.
13 Ventura and later/System/Volumes/Preboot/Cryptexes/OS/System/Library/dyld/Moved into the OS Cryptex so Rapid Security Responses can replace it. The kernel also accepts the /System/Cryptexes/OS/... view of the same files.

The kernel only lets a process map a cache from one of these known directories; the list is hard-coded in xnu:

apple-oss-distributions/xnubsd/vm/vm_unix.cscdir_path[]: the directories a shared cache may be mapped from on macOS, including the Preboot Cryptex path.View on GitHub(line —)

Next to the main dyld_shared_cache_<arch> file you will see numbered subcache files and a .symbols file holding local symbols. Tools need all of them, so copy the whole directory, not just the main file.

To get individual dylibs back out (for reversing or to read a framework's symbols):

  • ipsw dyld split <DSC> <output-dir> (blacktop/ipsw): extracts every dylib, using Xcode's dsc_extractor.bundle, so it runs on macOS only. ipsw dyld extract <DSC> <DYLIB> pulls out a single image and works on any OS.
  • dsc_extractor.bundle: the extractor Xcode ships; its source is in the dyld repo (other-tools/dsc_extractor.cpp).
  • dyld_shared_cache_util: Apple's inspection tool, built from the dyld source. It can -list images, print -info and -map, and -extract <directory>.
  • Disassemblers open the cache directly and let you pick the images you want: IDA Pro, Ghidra, Hopper and Binary Ninja all have shared-cache loaders.

arm64e vs x86_64 caches

The suffix in the file name is the architecture the cache is built for:

  • dyld_shared_cache_arm64e: Apple Silicon. arm64e is the arm64 ABI with pointer authentication (PAC), which all of Apple's own system code uses. Third-party apps are usually built as plain arm64, and they still map the arm64e cache: an arm64 process can call into arm64e system libraries.
  • dyld_shared_cache_x86_64 and dyld_shared_cache_x86_64h: Intel Macs. The h variant is optimized for Haswell and newer CPUs, and dyld picks it on hardware that supports it.
  • On Apple Silicon Macs with Rosetta 2 installed, an x86_64 cache is also present for translated Intel processes.

What surprises newcomers

  • Virtual size in Activity Monitor lies to you about real cost. The 1+ GB is mostly the shared cache, which is shared across every process.
  • The cache is per-architecture. Intel Macs had Intel caches; Apple Silicon Macs have arm64e caches. Universal binaries get the right one mapped.
  • You can technically bypass the cache with DYLD_SHARED_REGION=avoid (developer-only, requires SIP relaxed) for debugging — but the app loads dramatically slower.
  • The cache is the reason dlopen("libSystem") is essentially free — it's already mapped.

For dyld's open-source implementation:

apple-oss-distributions/dylddyld/Loader.cppThe Loader class — what represents each dylib (cached or otherwise) in dyld's runtime.View on GitHub(line —)

And the mmap article — the shared cache is a giant mmap-based mapping; understanding mmap makes the cache mechanics obvious.

For the cache's role in app startup, what happens when you launch an app — the cache map happens at step 3.

Related

From double-click to first window: LaunchServices, launchd, posix_spawn, AMFI, dyld, the shared cache, sandbox profile installation, the runloop. Six subsystems in three seconds.
How XNU allocates kernel memory: zalloc zones, the kalloc heap and its type-isolated buckets, and why zone hardening matters to kernel exploit writers.
How XNU responds when memory gets tight — the four-stage pressure pipeline from free pages through compression to swap to process termination, and what each stage costs.