On Tue, Aug 12, 2008 at 10:32 PM, Quincey Morris
<[EMAIL PROTECTED]> wrote:
> On Aug 12, 2008, at 21:22, Oleg Krupnov wrote:
>
>> Actually, I don't know how to "break on something". Would you please
>> tell me?
>
> Open the Breakpoints window (Run | Show | Breakpoints). Double click where
> it says "Double-click for symbol" and type the symbol name you want to break
> on (auto_refcount_underflow_error in this case) and press Return.
>
> If there's only one definition of that symbol (as in this case, I assume),
> you're done. Otherwise, you'll see a sheet listing all the places where the
> symbol is defined. You can click the checkbox for the one or ones you want
> to break on, then click Done.
>
>>                      CGPDFPageRef page = CGPDFDocumentGetPage(document,
>> 1);
>>                      if (page != nil)
>>                      {
>>                              // *******TODO: the page object causes
>> the reference count underflow
>>                              CFMakeCollectable(page);
>
> Since this is not a "create" method, you don't own the object, so you
> shouldn't release it unless you retain it first. (CFMakeCollectable
> internally calls CFRelease on the object.)

Oh, hm, that too.  Good point. :-)  There are a couple of problems in this code.

>> Instead, you should CFRetain the object when you get it, and CFRelease it
> when you're done with it -- even though this is a GC app.

In general, you don't need to CFRetain an object to keep it alive
while it's on the stack.  The fact that it's on the stack is enough.
If this wasn't true, there'd be a race, since the collector might
destroy the object before you retained it.

> If you want to keep the object alive with a strong reference instead of a
> retain count, I suppose it might work to call CFRetain followed by
> CFMakeCollectable immediately after, but I'm not sure if you're allowed to
> call CFMakeCollectable on an object you don't own. I don't see anything in
> the documentation about this, but I would avoid it if possible -- changing
> the memory management characteristics of an object you don't own doesn't
> seem like a good idea.
>
> Note that your other objects are obtained via a "create" method, so you do
> own them, and CFMakeCollectable is perfectly fine.
>
> _______________________________________________
>
> 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/kenferry%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>
_______________________________________________

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

Reply via email to