• 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: EXC_BAD_ACCESS when -fobjc-gc is on (Was: Memory corruption ...)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EXC_BAD_ACCESS when -fobjc-gc is on (Was: Memory corruption ...)


  • Subject: Re: EXC_BAD_ACCESS when -fobjc-gc is on (Was: Memory corruption ...)
  • From: Gabriel Zachmann <email@hidden>
  • Date: Wed, 7 Oct 2009 22:47:43 +0200

Thanks for the quick response.

I am still a bit confused ... and, besides, I still get a core dump ;-(

I think this is your problem right here. In a GC environment CALayer
isn't going to retain its content, it stores a strong reference
instead.

First of all, how can I know that? (I'm asking so that I can avoid such bugs in the future)


In the doc of CALayer.contents it says

   @property(retain) id contents

Does a retained property always translate to a strong reference in a GC environment?


I tried this

CGImageRef cgImage = CFMakeCollectable ( CGImageSourceCreateImageAtIndex( sourceRef, 0, NULL ) );
// [snip]
imgLayer.contents = (id) cgImage;
// [snip]
CGImageRelease( cgImage );
return imgLayer;


and this:

CGImageRef cgImage = CGImageSourceCreateImageAtIndex( sourceRef, 0, NULL );
// [snip]
imgLayer.contents = (id) cgImage;
// [snip]
CFMakeCollectable( cgImage );
return imgLayer;


Both yield the same crash at the same place.

Did I misunderstand something?

Or is the bug somewhere else?

In the guide it says that CFMakeCollectable() does a CFRelease() -- is that the same as a CGImageRelease() ?

But cgImage isn't collectable, so the strong reference does
nothing. Look at the documentaiton for CFMakeCollectable.

I did that and there is one sentence that I don't understand at all:

"CFMakeCollectable calls CFRelease, but has two supplementary features: [...]; second, it’s a no-op in a reference counted environment."

Shouldn't that be "a no-op in a GC environment." ?

Best regards,
Gabriel.

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

_______________________________________________

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: EXC_BAD_ACCESS when -fobjc-gc is on (Was: Memory corruption ...)
      • From: "Stephen J. Butler" <email@hidden>
    • Re: EXC_BAD_ACCESS when -fobjc-gc is on (Was: Memory corruption ...)
      • From: David Duncan <email@hidden>
  • Prev by Date: Re: feeble anti-aliasing
  • Next by Date: Re: [Xgrid] GridMandelbrot Sample gone?
  • Previous by thread: Re: EXC_BAD_ACCESS when -fobjc-gc is on (Was: Memory corruption ...)
  • Next by thread: Re: EXC_BAD_ACCESS when -fobjc-gc is on (Was: Memory corruption ...)
  • Index(es):
    • Date
    • Thread