5 ms·
Swift will need to do garbage collection at one time or another and then you are fu*ed.
by callesgg 10y ago
Swift will need to do garbage collection at one time or another and then you are fu*ed.
- plorkyeran 10y agoSwift is reference counted and does not pause at unpredictable times.
- deleted 10y ago[deleted]
- vardump 10y agoReference counting is a form of garbage collection. You can have avalanches of objects being deallocated when as a consequence of one object refcount reaching 0. You don't want any allocation or deallocation when you need realtime performance.
- plorkyeran 10y agoAn object's refcount being decremented is not an unpredictable time for a pause. If you never allocate or release objects on your audio worker thread, it will never be paused for GC, as the person I was replying to implied could happen.
- vardump 10y agoSure. But same can be said for pretty much any garbage collected system. If you don't create objects or cause objects to become unreachable, you also won't be creating garbage. So you won't have GC pauses. Unless the GC system is braindead and runs even when there's no heap pressure.
- plorkyeran 10y agoWith a stop-the-world garbage collector, allocations on other threads can result in your audio thread being paused, so you have to not be allocating objects on any thread, which is a significantly more difficult requirement than simply not allocating on your audio thread while audio playback is occurring.