Swift

Thread by @jacobtechtavern 1 3

**Jacob Bartlett** @jacobtechtavern [2026-04-22](https://x.com/jacobtechtavern/status/2047029684001525761)Swift has a secret sauce internally called Stack Promotion that quietly speeds up your code. When the compiler can predict an object’s exact size in memory and lifetime during the SILGen stage, it can optimise heap allocations (slow) into stack allocations (fast).The objects begin life with an \`unowned\` reference count of 2 instead of 1, ensuring the memory is never freed, since the count won’t reach zero. The object can still be deinited, but the memory is valid for the duration of the stack frame.Subscribe to my blog to accelerate your iOS career with new posts every week! 🚀 https://join.jacobstechtavern.comImage