2 ms·
Code in the fastpath must not generate substantial garbage whether using ARC or a gc. That's just a coding error.
by foobiekr 6y ago
Code in the fastpath must not generate substantial garbage whether using ARC or a gc. That's just a coding error.
- skohan 6y agoIt's not about garbage creation, is about reference cost. With ARC, you pay a penalty every time you pass a reference type, not only for memory churn. You can avoid this using value types, but this often results in a lot of unnecessary copying. It's not unavoidable, but Swift doesn't give good tools for avoiding ARC-based performance cliffs, so it takes a lot of profiling and effort compared to other languages.
- astrange 6y agoIt's ok to generate garbage if it goes away immediately; that's essentially a stack allocation. Performance problems come up when you have a mix of lifetimes. (that slows GCs down and causes heap fragmentation outside copying GCs)