Tag

Questions tagged “Memory Management

Start from this tag, then add more in the filter bar to narrow further. The URL keeps your choices so you can bookmark or share the same view.

What is the difference between NSCache and Dictionary?

Compare Dictionary and NSCache on one concrete example, an image cache for a photo feed, and show where the two diverge on thread safety, automatic eviction, and key and value rules

How would you demonstrate Copy-on-Write behavior with a custom struct?

Demonstrate Copy-on-Write with a value-typed linked list that shares storage on assignment and copies it only when a mutation occurs using isKnownUniquelyReferenced.

What's the difference between strong, weak, and unowned references?

Under ARC, strong keeps an object alive, unowned tracks a direct non-owning pointer that must outlive use, and weak goes through a side table so access can become nil after deinit

How does struct memory layout work in Swift?

Explain MemoryLayout, padding, alignment, and stride; show why stored-property order changes a struct's footprint; and connect it to arrays, performance, and low-level interop