Urgent.News

One page, thousands of outlets. See who else covered it.

Editions

Tech

Swift ARC Doesn’t Scan the Heap — I Removed strong_release from SIL to Prove It

Also available: Korean version · Source code and reproducible experiments A source-to-runtime experiment with Swift 6.3.1: inspect ownership in SIL, delete one strong_release , measure the resulting leak, compare weak-reference lowering, and follow the call stack into the Swift runtime. Swift ARC is sometimes explained as if it were a background service that periodically scans memory and frees…

This report examines the inner workings of Swift's automatic reference counting (ARC) system, contrasting it with a background service that periodically scans memory. Swift ARC operates by analyzing ownership and value lifetimes, represented as operations such as copy_value, destroy_value, strong_retain, and strong_release in the intermediate representation SIL.

These operations are lowered to runtime behavior like swift_retain and swift_release. When a release brings an object's strong reference count to zero, destruction begins on that execution path.

A test case was created to verify that removing the strong_release operation breaks the reference count chain, causing the object to remain alive and leading to a significant increase in memory usage. The SIL code for the original and modified versions of the test case are provided for comparison. The experiment demonstrates that the strong_release operation is critical for the proper functioning of Swift ARC.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Thursday 20 August →