In the Cocoa Garbage Collection Programming Guide, I do not see the convincing certainty that Ahruman does above, that the address of the object is guaranteed to be constant:
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/GarbageCollection/Articles/gcArchitecture.html
Section "Closed and open systems":
'[In an open garbage collection system, collectors] redistribute and copy blocks of memory and update each link pointer to reflect the new address. [...] Cocoa the garbage collector strikes a balance between “closed” and “open”, knowing exactly where the pointers to scanned blocks are located anywhere, easily tracking “external” links and being “conservative” only where it should. ''
And with the general “dynamic” nature of Cocoa's runtime, I would like an explicit discussion of the subject in Apple documentation even for a non-garbage-related program. I don’t find any claim that “the object’s memory address is guaranteed to not change” when searching the entire developer.apple.com site - try Google with
site:developer.apple.com cocoa "object memory address" OR "memory address of an object" guaranteed OR permanent
And there is this terrible thing ... multithreading (ahhhh).
source share