Re: Non-NSObject object and garbage collection
Re: Non-NSObject object and garbage collection
- Subject: Re: Non-NSObject object and garbage collection
- From: Quincey Morris <email@hidden>
- Date: Tue, 12 Aug 2008 22:32:26 -0700
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.)
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.
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 (email@hidden)
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:
This email sent to email@hidden