small medium large xlarge

26 Jan 2009, 13:20
Leonard Lin (2 posts)

I’m pretty new at Obj-C/Cocoa so hopefully I’m not asking something too obvious, but I seem to be having some pretty big memory leaks and I’m not quite sure the best way to track it down.

Basically, I have a NSTimer-called method where I’m loading up a new image and displaying it in a CALayer (setting CALayer.contents). I have a NSAutoreleasePool subpool set up for the method (since NSTimer’d calls get launched in a separate thread? and I’m releasing all the various CGImage bits that I’m explicitly calling, including the CGImageRef after I set it to CALayer.contents. Do I need to also call a release on CALayer.contents when I’m switching the layer contents?

26 Jan 2009, 14:08
Bill Dudney (916 posts)

Hi Leonard,

First off, welcome!

Sounds like something that could/should be autoreleased is not being autoreleased. Have you had a chance to run the app in Instruments with the Leaks instrument enabled? That might go a long way to nailing down the stuff that is really leaking.

Good luck and let us know what you find.

04 Feb 2009, 16:06
Leonard Lin (2 posts)

Hi Bill, thanks for the welcome.

I did end up tracking the leaks down. The alarming memory growth was just CA doing its thing, but there were leaks w/ various Core Foundation created objects that I’ve since ferreted out. I used the Leaks and MallocDebug instruments and also leaks(1), which was quite useful.

You must be logged in to comment