On Nov 12, 2008, at 9:30 AM, Karl Moskowski wrote:
I've been working on a Foundation tool project with garbage collection, and I've been wondering, what's needed (besides making GC required in the Xcode project) to ensure the garbage collector actually does its thing. Is it enough to call objc_startCollectorThread() once in main()? Should I also/instead call [NSGarbageCollector defaultCollector]?

objc_startCollectorThread() is required and that is it. The collector will run automatically

Depending on what you are doing, you may want to occasionally clear the stack using objc_clear_stack() to ensure that nothing is falsely rooted on the stack. You'll typically want to do this when the stack is as shallow as possible -- the top of your processing loop, if you have one.

You can also use objc_collect(OBJC_COLLECT_IF_NEEDED) to hint to the collector that a particular moment in the computation there may be a bunch of garbage to be collected.

b.bum

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [EMAIL PROTECTED]

Reply via email to