|
|
|
|
|
by steveklabnik
3735 days ago
|
|
It's all good! This is a very subtle difference. So, imagine an interface to a reference counted thing. You have two methods: rc.add()
rc.subtract()
Add bumps the count, subtract drops the count down. When the count hits zero, the thing is deallocated.What Swift's _automatic_ reference counting is insert the calls to add/subtract _for you_, so that you don't need to do it. But fundamentally, they're still there. So the decision of "when does this get deallocated" is still a runtime thing, even though those calls are compiler inserted. Does that make sense? Here's another reference: http://stackoverflow.com/questions/6385212/how-does-the-new-... |
|
Obviously, even in C the memory management is a high-level runtime abstraction of sorts (neither the programmer nor the compiler is choosing the actual addresses in memory to alloc/dealloc), so at what point on the continuum of C++-style RAII, Obj-C RC, Swift ARC and so on would you say "garbage collection" comes into play? Is it just one of those "I know it when I see it" type things?