On Jan 4, 2010, at 2:27 PM, Oftenwrong Soong wrote:

> According to the docs, the collector "scans" all of your objects to determine 
> what needs to be deallocated. But in performing this scan, how does it "know" 
> which bits in your object are pointers to other objects and which bits are 
> just data?

The Objective-C compiler has always generated extended type information for 
classes, so you can not only tell what the offset of an instance variable is at 
runtime, but also what its type is.

When building GC-supported or GC-required, the compiler additionally provides a 
layout bitmap that gives the collector a faster way to know what offsets should 
be considered to hold strong and weak references.  See class_setIvarLayout and 
class_setWeakIvarLayout in the Objective-C Runtime Reference; anyone 
constructing classes “by hand” (e.g. using objc_allocateClassPair) needs to use 
these if they want their classes to work under GC.

  — Chris

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to