~/talk

Exploring Swift Memory Layout

Talkat GOTO Copenhagen 2016 · 2016-10-03..10-06· [swift]
name:Mike Ash
links:none on file
slides:none on file

A small program in Swift 3 and Xcode 8 crawls live process memory, using mach_vm_read_overwrite for safe reads, malloc_size and dladdr to size and name regions, then emits Graphviz to visualize object graphs; it runs on x86-64 macOS and produces PDFs that match expectations. Key findings: Swift structs and classes lay out like C/C++ with padding, arrays are reference-backed, protocol values are five words (three inline + metadata + witness table), and enums pack variably; the tool works and reveals surprising boxing thresholds.

AI-written summary · about

  1. 0:00Introduction
  2. 0:31About Me
  3. 6:19Memory - Big Picture
  4. 9:47Dumping Memory
  5. 14:50Pointers are Integers
  6. 16:51Bad Pointers
  7. 19:43Safe Reads
  8. 20:17How Much to Read?
  9. 22:23Name Mangling
  10. 23:48Strings
  11. 25:29Output
  12. 26:05Graphviz
  13. 27:23Memory Layouts
  14. 28:19C structs
  15. 30:17C++ classes
  16. 36:03Swift Types
  17. 42:26Objective-C Classes
  18. 43:30Swift Classes
  19. 44:11Method Calls
  20. 44:42Subclasses
  21. 45:14Arrays
  22. 46:15Protocols
  23. 49:38Protocol Method Call
  24. 50:41Enums
  25. 53:28Wrapping Up
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.