On Tue, Oct 15, 2013, at 12:50 PM, Steve Mills wrote:
> We have extended NSMenu so we could add some other methods. Many of the
> methods iterate over the itemArray like so:
> 
>       for(NSMenuItem* item in [self itemArray])
> 
> Instruments shows that we're leaking NSArrays created when itemArray
> returns. I assume whoever wrote these methods was assuming that itemArray
> would simply return the internal NSArray and not make a copy. I guess I
> would make the same assumption since it's not a copy* method.

They shouldn't be leaking. You're correct that -itemArray doesn't follow
the naming convention of an object-creation method (new, alloc, copy,
etc.), so you should not assume a +1 owning reference.

Are you perhaps seeing an autoreleased object hang out longer than you
expected, but not actually get leaked?

--Kyle Sluder
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to