• 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: Window controllers and memory leaks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Window controllers and memory leaks


  • Subject: Re: Window controllers and memory leaks
  • From: Dave <email@hidden>
  • Date: Fri, 13 Sep 2013 18:28:30 +0100

On 13 Sep 2013, at 17:12, Jonathan Taylor <email@hidden> wrote:
>
>
> However the static analyzer complains that there is a "potential leak" of myWindowController, because it recognises that it has a retain count of 2 when it returns from the init method. (The same applies if I don't retain in init and don't release in TestWindowController).
>
> It strikes me that this would be quite a common pattern. I appreciate that the static analyzer doesn't *know* whether there's a leak or not, but if I am indeed correctly following a common pattern then I would have expected the analyzer to understand what is going on.
>
> My question then is whether I am doing things in an unconventional way here, and/or whether there is something I could change that would help the analyzer understand what is going on.

It's complaining because init is not a "special" (alloc, copy, new, magic method), normally the pattern I would use is to put it into a property and then release it at dealloc time. That way the property is holding a reference to the object and then analyser won't complain!

Cheers
Dave


_______________________________________________

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


References: 
 >Window controllers and memory leaks (From: Jonathan Taylor <email@hidden>)

  • Prev by Date: Re: Helper tool
  • Next by Date: Re: ARC vs Manual Reference Counting
  • Previous by thread: Window controllers and memory leaks
  • Next by thread: Re: Window controllers and memory leaks
  • Index(es):
    • Date
    • Thread