• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Non-NSObject object and garbage collection
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Non-NSObject object and garbage collection


  • Subject: Re: Non-NSObject object and garbage collection
  • From: "Oleg Krupnov" <email@hidden>
  • Date: Wed, 13 Aug 2008 06:46:33 +0300

I have added a call to CFMakeCollectable each time after I create a CF
object like this

CFSomeTypeRef a = CFCreateSomeType();
if (a != nil)
{
    CFMakeCollectable(a);
}

But I keep getting this runtime message in the console:
malloc: reference count underflow for 0x10773c0, break on
auto_refcount_underflow_error to debug.

All CF objects I create are local vars in scope of one single
function, no instance or global vars. I create several CF objects,
some of them are used as arguments for other functions. The error is
issued only for one of the CF objects I create, the other work fine.

What can be the problem?

On Mon, Aug 11, 2008 at 3:25 PM, Antonio Nunes <email@hidden> wrote:
> On 11 Aug 2008, at 13:14, Antonio Nunes wrote:
>
>>> Will it cause a memory leak if I treat the Quartz object in the same
>>> way as I do to all my NSObject descendants, i.e. no retains and rely
>>> only on garbage collection?
>>
>> You either take care of the object's life time manually as you would in a
>> non-garbage collected environment, or you explicitly move it into the realm
>> of the garbage collector. Lookup "CFMakeCollectable" and "NSMakeCollectable"
>> in the docs.
>
> I should add: read the "Memory Management Semantics" in "Using Core
> Foundation with Garbage Collection" in the "Garbage Collection Programming
> Guide", which has a thorough explanation of how to handle CF objects under
> GC.
>
> António
>
> ----------------------------------------------------
> It isn't so important to do great things,
> as to do what you do with great love.
> ----------------------------------------------------
>
>
>
>
_______________________________________________

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

  • Follow-Ups:
    • Re: Non-NSObject object and garbage collection
      • From: "Ken Ferry" <email@hidden>
References: 
 >Non-NSObject object and garbage collection (From: "Oleg Krupnov" <email@hidden>)
 >Re: Non-NSObject object and garbage collection (From: Antonio Nunes <email@hidden>)
 >Re: Non-NSObject object and garbage collection (From: Antonio Nunes <email@hidden>)

  • Prev by Date: Re: Should I retain a variable returned from this accessor?
  • Next by Date: Re: Non-NSObject object and garbage collection
  • Previous by thread: Re: Non-NSObject object and garbage collection
  • Next by thread: Re: Non-NSObject object and garbage collection
  • Index(es):
    • Date
    • Thread