• 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: autorelease CGImageRef?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: autorelease CGImageRef?


  • Subject: Re: autorelease CGImageRef?
  • From: Negm-Awad Amin <email@hidden>
  • Date: Wed, 6 Aug 2008 15:08:37 +0200


Am Mi,06.08.2008 um 14:26 schrieb Jean-Daniel Dupas:

Be carefull when you mix CFType memory management, and obj-c memory management.
It works well when you do not use GC, but may become problematic if you do not take special care with GC code.
IIRC, there are some rules:
1 GC respects reference counting. That means, that GC will not deallocate any instance with an RC greater than 0.
2 RC methods of objective-C (-retain, -release) are "dead". That means that no change of the RC is applied.
3 (1+2) Using GC and -retain, -release leads to the situation, that the RC is never greater than 0. So GC behaves as intended: GC respects the RC, but there is no RC to respect. (Even it works: You should not mix up GC and RC methods.)
4 RC functions of CF are still working. That means, that they do change the RC.
5 (1+4) Using CF-RC leads to the situation, that (by CF) referenced instances are not collected by the GC.


5 is a feature, because you can hold instances in memory without having a reference to it.

Amin



If I'm not wrong, it should be something like this:

[NSMakeCollectable(aCGImageRef) autorelease];


Le 6 août 08 à 12:16, Mike Abdullah a écrit :

Since CGImage is derived from CFType you can just do:

[(id)aCGImageRef autorelease]

The reason being that CFType knows how to handle a -release message, and autorelease is just a way of deferring that message.

On 6 Aug 2008, at 09:29, Peter N Lewis wrote:

Given a CGImageRef, how can I autorelease it?

Perhaps this is obvious, or perhaps its impossible, but googling hasn't found me the answer yet except for a tantalizing comment in the docs for NSBitmapImageRep:

- (CGImageRef)CGImage (added in 10.5)
"Returns an autoreleased CGImage object (an opaque type) from the receiver's current bitmap data."


For CFStringRef, I know I can cast it to an NSString* and then autorelease it, but is there an equivalent for CGImageRef?

Thanks,
Peter.

--
           Keyboard Maestro 3 Now Available!
             Now With Status Menu triggers!

Keyboard Maestro <http://www.keyboardmaestro.com/> Macros for your Mac
<http://www.stairways.com/> <http://download.stairways.com/ >
_______________________________________________


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

_______________________________________________

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


_______________________________________________

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

Amin Negm-Awad email@hidden




_______________________________________________

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: autorelease CGImageRef?
      • From: "Shawn Erickson" <email@hidden>
References: 
 >autorelease CGImageRef? (From: Peter N Lewis <email@hidden>)
 >Re: autorelease CGImageRef? (From: Mike Abdullah <email@hidden>)
 >Re: autorelease CGImageRef? (From: Jean-Daniel Dupas <email@hidden>)

  • Prev by Date: Re: autorelease CGImageRef?
  • Next by Date: Re: How to debug a corrupted stack
  • Previous by thread: Re: autorelease CGImageRef?
  • Next by thread: Re: autorelease CGImageRef?
  • Index(es):
    • Date
    • Thread