Design Element
Comment on "CoreAnimation Sample Code: ArtGallery"
by Scott Stevenson — May 26
@ssp: the comments in your code suggests that you're not really convinced about the -cgImage method in your NSImage Extras category

It works fine, it just seemed very brute force-ish to me at first. At this point, I think it's probably the best solution, and it's very simple at two lines of code.

How far does that go? In particular: What about memory usage/leakage?

As long as you CFRelease() or CGImageRelease() the result at some point, it's fine. I'm pretty sure ArtGallery does that correctly.

And from what I could tell, the 500MB of memory my app leaked [...] for drawing a few NSBezierPaths into a layer all come from the TIFFRepresentiations created when getting the CGImageRef.

You definitely need to release the images that you create. If you find a specific case where CFRelease() or CGImageRelease() isn't freeing the reference, then it's a bug that should be filed.

Even if you have garbage collection turned on, CF-style objects are not automatically picked up by the collector. Read more about it in "Using Core Foundation with Garbage Collection" at ADC.
Back to "CoreAnimation Sample Code: ArtGallery"
Design Element

Copyright © Scott Stevenson 2004-2015